ericbartha

Child GUI Not dragging with parent

3 posts in this topic

#1 ·  Posted (edited)

Hey everyone,

I am trying to get a child GUI "log in" box to drag with the main window of the application, yet it is not. I've read through a bunch of other threads with similar issues, but cannot seem to find a resolution. I've only started learning to make GUI's 3 days ago, so I am hoping someone a little more experienced can identify my flaw. Here's my code:

#include <Inet.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <ButtonConstants.au3>
#include <AutoItConstants.au3>

Global $sMainDir = "G:\Eric\LoginGUITesting\"

formLogIn()

Func formLogIn()

    Local $iFormBGState = WinGetState("BT Dashboard")

    If BitAND($iFormBGState, 1) Then

        ; Do Nothing

    Else

        Local $f_programBG = GUICreate("BT Dashboard", @DesktopWidth, @DesktopHeight - 40, 0, 0, $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX)
        GUISetBkColor(0x333333, $f_programBG)
        GUISetIcon($sMainDir & "Images\hacuIcon.ico")
        GUISetState(@SW_SHOW, $f_programBG)
        WinSetState($f_programBG,"",@SW_MAXIMIZE)

    EndIf

    Local $f_logIn = GUICreate("f_logIn", 350, 400, -1, -1,$WS_POPUP, $WS_EX_TOPMOST, $f_programBG)
    GUISetBkColor(0xFFFFFFF)
    GUISetState(@SW_SHOW, $f_logIn)

    Local $shape_headerLine = GUICtrlCreateGraphic(30, 70, 290, 2)
    GUICtrlSetBkColor($shape_headerLine, 0xEAEAEA)

    Local $l_header = GUICtrlCreateLabel("Login Form", 30, 20, 200, 50)
    GUICtrlSetFont($l_header, 22, 400, "", "Segoe UI", $CLEARTYPE_QUALITY)
    GUICtrlSetBkColor($l_header, 0xFFFFFF)
    GUICtrlSetColor($l_header, 0x009BAA)

    $tabHolder = GUICtrlCreateTab(0, 0, 1, 1)
    GUICtrlSetBkColor($tabHolder, 0xFFFFFF)

    Local $sUserNameFocus = "Email Address"
    Local $i_userName = GUICtrlCreateInput("", 60, 128, 250, 29)
    GUICtrlSendMsg($i_userName, $EM_SETCUEBANNER, False, $sUserNameFocus)
    GUICtrlSetBkColor($i_userName, 0xF0EEF0)
    GUICtrlSetColor($i_userName, 0x333333)
    GUICtrlSetFont($i_userName, 12, 500, "", "Segoe UI", $CLEARTYPE_QUALITY)
    GUICtrlSetTip($i_userName, "Enter a valid email address", "Username", $TIP_INFOICON, $TIP_CENTER)

    GUICtrlCreatePic($sMainDir & "Images\userIcon.bmp", 36, 136, 12, 12, $BS_BITMAP)

    Local $sPasswordFocus = "Password"
    Local $i_password = GUICtrlCreateInput("", 60, 176, 250, 29)
    GUICtrlSendMsg($i_password, $EM_SETCUEBANNER, False, $sPasswordFocus)
    GUICtrlSetBkColor($i_password, 0xF0EEF0)
    GUICtrlSetColor($i_password, 0x333333)
    GUICtrlSetFont($i_password, 12, 500, "", "Segoe UI", $CLEARTYPE_QUALITY)
    GUICtrlSetTip($i_password, "Enter your matching password", "Password", $TIP_INFOICON, $TIP_CENTER)

    GUICtrlCreatePic($sMainDir & "Images\passIcon.bmp", 35, 183, 15, 15, $BS_BITMAP)

    Local $l_forgotPass = GUICtrlCreateLabel("Forgot your password?", 60, 230, 120, 17)
    GUICtrlSetFont(-1, 8, 400, 0, "Segoe UI")
    GUICtrlSetColor($l_forgotPass, 0x009BAA)
    GUICtrlSetFont($l_forgotPass, 9, 500, "", "Segoe UI", $CLEARTYPE_QUALITY)

    Local $l_requestLogin = GUICtrlCreateLabel("Request credentials", 60, 260, 103, 17)
    GUICtrlSetFont(-1, 8, 400, 0, "Segoe UI")
    GUICtrlSetColor($l_requestLogin, 0x009BAA)
    GUICtrlSetFont($l_requestLogin, 9, 500, "", "Segoe UI", $CLEARTYPE_QUALITY)

    Local $b_logIn = GUICtrlCreateButton("", 0, 325, 350, 75, $BS_BITMAP)
    GUICtrlSetImage($b_logIn, $sMainDir & "Images\loginButton.bmp")

    While 1

        Local $nMsg = GUIGetMsg()

        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

            Case $l_forgotPass
                GUIDelete("f_logIn")
                formResetPass()

            Case $l_requestLogin
                MsgBox(0,"","Login Requested")

            Case $b_logIn
                Local $inputReturn = GUICtrlRead($i_userName)
                MsgBox(0,"", $inputReturn)

        EndSwitch
    WEnd
EndFunc

Func formResetPass()

    Local $f_passReset = GUICreate("f_passReset", 350, 300, -1, -1, $WS_POPUP + $WS_TABSTOP)
    GUISetBkColor(0xFFFFFF)

    Local $l_header = GUICtrlCreateLabel("Password Reset", 30, 20, 200, 50)
    GUICtrlSetFont($l_header, 22, 400, "", "Segoe UI", $CLEARTYPE_QUALITY)
    GUICtrlSetBkColor($l_header, 0xFFFFFF)
    GUICtrlSetColor($l_header, 0x009BAA)

    Local $shape_headerLine = GUICtrlCreateGraphic(30, 70, 290, 2)
    GUICtrlSetBkColor($shape_headerLine, 0xEAEAEA)

    $tabHolder = GUICtrlCreateTab(0, 0, 1, 1)
    GUICtrlSetBkColor($tabHolder, 0xFFFFFF)

    Local $sUserNameFocus = "Email Address"
    Local $i_userName = GUICtrlCreateInput("", 60, 128, 250, 29)
    GUICtrlSendMsg($i_userName, $EM_SETCUEBANNER, False, $sUserNameFocus)
    GUICtrlSetBkColor($i_userName, 0xF0EEF0)
    GUICtrlSetColor($i_userName, 0x333333)
    GUICtrlSetFont($i_userName, 12, 500, "", "Segoe UI", $CLEARTYPE_QUALITY)
    GUICtrlSetTip($i_userName, "Enter a valid email address", "Username", $TIP_INFOICON, $TIP_CENTER)

    GUICtrlCreatePic($sMainDir & "Images\userIcon.bmp", 36, 136, 12, 12, $BS_BITMAP)

    Local $l_ReturnLogIn = GUICtrlCreateLabel("Return to the Login Screen", 60, 175, 140, 17)
    GUICtrlSetFont(-1, 8, 400, 0, "Segoe UI")
    GUICtrlSetColor($l_ReturnLogIn, 0x009BAA)
    GUICtrlSetFont($l_ReturnLogIn, 9, 500, "", "Segoe UI", $CLEARTYPE_QUALITY)

    Local $b_passReset = GUICtrlCreateButton("", 0, 225, 350, 75, $BS_BITMAP)
    GUICtrlSetImage($b_passReset, $sMainDir & "Images\passResetButton.bmp")

    GUISetState(@SW_SHOW)

    While 1

        Local $nMsg = GUIGetMsg()

        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

            Case $l_ReturnLogIn
                formLogIn()
                GUIDelete("f_passReset")

            Case $b_passReset
                Local $inputReturn = GUICtrlRead($i_userName)

                If $inputReturn = "" Then

                    MsgBox(0,"Error","Please enter a valid e-mail Address")

                Else

                    ; email variables removed
                    
                    ProgressOn("Password Reset", "Sending Reset Email" , "Initiating...")
                    ProgressSet(0)

                    ProgressSet(20, "Sending email to " & $sToAddress & "...")
                    ; disabled and removed Local $emailCheck = _INetSmtpMail()

                    If Not $emailCheck Then

                        MsgBox(0,"","Email could not be sent. Please try again later or contact your system admin.")
                        ProgressOff

                    Else

                        ProgressSet(60, "Checking for successfully sent email...")

                        ProgressSet(100, "Successfully sent password reset email...")
                        Sleep(200)
                        ProgressOff()

                        MsgBox(0,"","Thank you. You should receieve an email shortly with instructions on how to reset your password.")

                        formLogIn()
                        GUIDelete("f_passReset")

                    EndIf
                EndIf

        EndSwitch
    WEnd

EndFunc

I am really lost on this one, so any help would be appreciated! Oh - and since the GUI does contain custom images, here is a screenshot to help you visualize.

Untitled.png

Thanks, everyone!

Eric

Edited by ericbartha

Share this post


Link to post
Share on other sites



$WS_CHILD   :) 

Local $f_logIn = GUICreate("f_logIn", 350, 400, -1, -1,$WS_CHILD, $WS_EX_TOPMOST, $f_programBG)

 

1 person likes this

Share this post


Link to post
Share on other sites

... I ... no words. I completely missed that one. It works perfectly now.

Thanks, Mikell. :>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • anusha
      By anusha
      Hi I have jus started using auto-it . Please correct me if I'm wrong.
      I need to read data from an input in text box and search in excel file and return value in next column of matched cell on GUI.
      I have written below code but i cannot use variable which has data stored. it works only when search string is hard coded.
      Please help out.
       
      Example()
      Func Example()
      Local $GuiMain = GUICreate("EXCEL TEST", 399, 180) ;creates main GUI
      ;~ Local $idOK = GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
      Local $iWidthCell = 70
      Local $idLabel = GUICtrlCreateLabel("PART NUMBER", 10, 30, $iWidthCell,50)
      Local $RUN_1 = GUICtrlCreateButton("OK", 70, 70, 85, 25)
      Local $Input_1 = GUICtrlCreateInput("PART NUMBER", 100, 20, 120, 20)
      Local $sMenutext = GUICtrlRead($Input_1, 1)
      GUISetState(@SW_SHOW, $GuiMain)

          While 1
          $MSG = GUIGetMsg()
          Select
              Case $MSG = $GUI_EVENT_CLOSE
                  Exit
              Case $MSG = $RUN_1
                  Local $oAppl = _Excel_Open()

      Local $sFilePath1 = "D:\Anu_WorkFolder\Components.xlsx"
      Local $oWorkbook = _Excel_BookOpen($oAppl, $sFilePath1, Default, Default, True)
      Local $aResult = _Excel_RangeFind($oWorkbook, $sMenutext , Default, Default, $xlWhole)
    • X_xkijux_x
      By X_xkijux_x
      Ok so im using this program. clarify for school. I would like to have a program that takes every word i type in microsoft word and searches on it in claryfi. is this possible. I would like to have the program not stopping me from typing more after that word. Like when i type a word it auto search it on clarify without making me stop typing and if i want to change i can do that and if im fine that word i can just keep typing and it will search after the next word. 
    • Miliardsto
      By Miliardsto
      Is this possible to make program works like in diagram? There is so much encryption methods and UDFs are they give security? If the $Address will be crypted with some encryption algorithm could be possible to get the value of $Address in easy way? Of course We know its easy too look into autoit code and get value of variable and so We dont want to anyone see $Address value - there are functions Could func1.au3, func2.au3.. be for example func1.php or other type of file? As we know .php files are unnable to see. For example func1 would be read by FileRead() and then Execute() Is this generally possible to do?
      Will it give secure?
      What do you think about? Maybe there is something wrong in this concept or missed.

    • JaredStroeb
      By JaredStroeb
      I need to open an application and send it keys in Session 0.  I have exe's working locally, I can see the application open in session 0 through interactive services, but my send commands do not go to the application.  The following article running-autoit-session-0, directs me to use ControlSend() however my application has no controls that can be identified by AutoIt v3 Window Info.  Get All Windows Controls also returned nothing for the application's handle.  
      What are my options?  
      Can this be done with AutoIt?
      Is there a different "relatively simple" library/tool to use? (I am familiar with C# if there is a viable library there )

       
    • Miliardsto
      By Miliardsto
      Hello.
      Drag option works only on parent window but as we can see on the parent gui is showed up child gui (on the right side with the color).
      Desired action is when we want to drag whole program we can also drag child gui and child gui will drag with parent gui.
      How to do this?
       
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> GUIRegisterMsg($WM_NCHITTEST, "_NCHITTEST") $hGUI = GUICreate("Test", 500, 500, -1, -1) $cButton_0 = GUICtrlCreateButton("Child 0", 10, 10, 80, 30) $cButton_1 = GUICtrlCreateButton("Child 1", 10, 50, 80, 30) $cButton_2 = GUICtrlCreateButton("Child 2", 10, 90, 80, 30) GUISetState(@SW_SHOW, $hGUI) ; guis Global $hChild_[3] Global $countGUI = UBound($hChild_) - 1 ;MsgBox("","",$countGUI) ; licznik dla GUI Global $gui = 0 $hChild_[0] = GUICreate("Child 0", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFF0000) GUISetState(@SW_SHOW, $hChild_[0]) $hChild_[1] = GUICreate("Child 1", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x00FF00) GUISetState(@SW_HIDE, $hChild_[1]) $hChild_[2] = GUICreate("Child 2", 350, 300, 150, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0x0000FF) GUISetState(@SW_HIDE, $hChild_[2]) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_0 _All_Hide() GUISetState(@SW_SHOW, $hChild_[0]) $gui = 0 Case $cButton_1 _All_Hide() GUISetState(@SW_SHOW, $hChild_[1]) $gui = 1 Case $cButton_2 _All_Hide() GUISetState(@SW_SHOW, $hChild_[2]) $gui = 2 EndSwitch WEnd Func _All_Hide() GUISetState(@SW_HIDE, $hChild_[0]) GUISetState(@SW_HIDE, $hChild_[1]) GUISetState(@SW_HIDE, $hChild_[2]) EndFunc Func _NCHITTEST($hWnd, $uMsg, $wParam, $lParam) If $hWnd = $hGUI Then Local $aPos = WinGetPos($hWnd) If Abs(BitAND(BitShift($lParam, 16),0xFFFF)- $aPos[1]) < 500 Then Return $HTCAPTION EndIf Return $GUI_RUNDEFMSG EndFunc