Jump to content
Sign in to follow this  
BlackEvil

About window

Recommended Posts

BlackEvil

Hi,

I have a GUI application, which works fine without any issues. I added an "About" button" and used pop_up style window to show the About of the app when i click on the button. When i click on the OK in about window the window closes. but the main GUI fails to respond to the mouse clicks then onwards. I am not sure how to handle child windows. can somebody throw some light?

I am using a child window got from this forum. its code is as below (it is slightly modified to meet my rqmnts :idea: )

#include <GuiconstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>

Global $hGUI;,$parent

HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    GUIDelete($hGUI)
EndFunc   ;==>On_Exit

;~ local $parent ;uncomment this two lines to work independently
;~ ShowAbout($parent)

Func ShowAbout($parent)
    ;$hGUI = GUICreate("X", 300, 100, -1, -1, BitOR($WS_POPUP,$WS_BORDER))
    $hGUI = GUICreate("X", 300, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER));,Default,$parent)
    $Progress = GUICtrlCreateProgress(-2, 140, 304, 10, $PBS_MARQUEE)
    $h_Prgrs = GUICtrlGetHandle($Progress)
    _SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 10) ; final parameter is update time in ms
    $hButton = GUICtrlCreateButton("OK", 205, 108, 81, 25)

    $AppName = GUICtrlCreateLabel(" Readme Creator", 14, 22,240, 25)
    $AppVer = GUICtrlCreateLabel("Ver: 0.9", 14, 50)
    GUICtrlSetFont($AppName,14,400,2, "Times New Roman",5)

    $Label1 = GUICtrlCreateLabel("Programmed in AutoIT V3.3.6.1", 14, 90)

    GUIRegisterMsg($WM_NCHITTEST, "_NCHITTEST")
    GUISetBkColor(0x00E0FFFF,$hGUI)  ; will change background color
    GUICtrlSetBkColor($hButton, 0x00A0FFFF)  ; will change background color
    GUICtrlSetBkColor($h_Prgrs, 0x00A0FFFF)  ; will change background color

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ;Exit
                GUIDelete($hGUI)
            Case $hButton
                ;Exit
                GUIDelete($hGUI)
        EndSwitch
    WEnd
EndFunc   ;==>ShowAbout

Func _NCHITTEST($hWnd, $uMsg, $wParam, $lParam)

    If $hWnd = $hGUI Then
        Local $aPos = WinGetPos($hWnd)
        If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $aPos[1]) < 100 Then Return $HTCAPTION
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_NCHITTEST

one more thing is i need the about window should be blocking. ie main gui should be accessible only after closing the "about"

Share this post


Link to post
Share on other sites
zorphnog

Unregister the $WM_NCHITTEST message when you exit the About window.

GUIRegisterMsg($WM_NCHITTEST, "")

Share this post


Link to post
Share on other sites
zorphnog

@billo is correct. I totally overlooked the endless loop you have.

Share this post


Link to post
Share on other sites
BlackEvil

@billo. Thank you for the help extended.

I updated the code sections like this

Func On_Exit()
    $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>On_Exit

and

While 1
        Select
            Case $msg = $GUI_EVENT_CLOSE OR $msg = $hButton
                ;Exit
                ExitLoop
        EndSelect
        $msg = GUIGetMsg()
    WEnd
    GUIDelete($hGUI)
    GUIRegisterMsg($WM_NCHITTEST, "")

It works fine. But now i notice another issue. I have the same progress bar as in about window in main GUI. It does not appear if i view "about" and then close it. Everything else works fine.

@zorphnog: thanks for the update. Do i have to Unregister the $WM_NCHITTEST message when you exit the About? I added it after GUI delete. But my issue doesnot solve.

My second question is : I need the about window blocking. how to do it?

Share this post


Link to post
Share on other sites
BlackEvil

Solved the second question: (parent child issue) by giving the main gui handle to About window.

Share this post


Link to post
Share on other sites
BlackEvil

any help for me?

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
Sign in to follow this  

×