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

    • Skeletor
      By Skeletor
      MS Splash Screens
      The office 2016/17 office suite has made many people turn heads with its functions and especially their splash screen.
      I now present to you, the MS Style Splash Screen. For Rookies, Novices and anyone who wants a ready made splash screen for your gui application.

      You can now download it and also try it out yourself.
      You have three colors to choose from:
      Blue
      Red
      Green
      All three colours are from the famous programs.
      I also included the KODA form to you can have freedom with this splash screen.
      Note: the KODA form does not have the three colours as well as the correct blue. 

      Have fun and enjoy.
      Note:
      I will update the splash to add the automated 3 dots animation at a later stage. 
       
       
    • Skeletor
      By Skeletor
      A gui splash screen. Themed after the famous MS Office Suite.
      Three colours to choose from, Red, Blue and Green.
      You can change the labels to your own application.

      Also bundled with this is the KODA form. So you can open up and see the basic structure of this splash screen.
       
      Splash Screen GUI.zip
    • BlazerV60
      By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian
    • SteveJM
      By SteveJM
      I have a working program currently driven largely through menu selections. I would like to add a toolbar where most of the tollbar button actions are basically the same as menu items, but quicker to access. I have been wading around in toolbar examples, MSDN pages etc, it's clearly going to be a bit of a slog to get everything right, including tooltips etc. I thought I would start with something simple to prove the principle.
      Using bits from the help file examples I have a small program that successfully displays a toolbar. However, what seemed like the most elegant way to deal with the button commands does not seem to work. My understanding was that a toolbar button fires a WM_COMMAND message, with the command Id set by the second parameter in the call to
      _GUICtrlToolbar_AddButton ( $hWnd, $iID, $iImage)
      so I though it would be a good idea to set this Id to the same value as my menu item Id; then it would run the same task which is what I wanted. This did not work. I am using message loop mode and would like to stick with this because some of my scripts run hardware at the same time as the gui; it is easier if I don't have to worry about code being interrupted with the hardware in an unknown state . So I added a handler for WM_COMMAND, with some cribbed display code to try and see why. The toolbar button defintely fired a WM_COMMAND message and the Id looked the same, so no explanation there.
      I guess the issue is with GUIGetMsg() which may be constructed to ignore all but a limited number of control handles, i.e. those made with the GuiCtrlCreate... commands; this is speculation.
      I would dearly love to find a tidy way to get around this. Having some controls handled in the message loop and some in a WM_COMMAND handler, performing the same task, feels ugly. I would be very grateful for further insight from someone experienced with handling a toolbar. Perhaps I should be trying to fire the menu item. I have attached a code snippet to try and illustrate the issue.
       
       
       
      ToolbarTrial.au3
    • sree161
      By sree161
      Hi,
      i have a code which generates two numeric outputs.i have to save them in excel.
      Is there any way to export them to specific cells in excel???