gil900

Question about GUIRegisterMsg

11 posts in this topic

Hello,

What is the correct way to un-register function that registered with GUIRegisterMsg ?

This is my case - I registered the function "MY_WM_COMMAND" with this line:

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

It works.

But I didn't saw in the help file how to unregister this function. So  I thought to check it out.

I found that this line:

GUIRegisterMsg($WM_COMMAND, "")

Seems to work  because I see that after this line was run, the MY_WM_COMMAND is not called when I click on some  button..

But I still not sure this is the right way ..

This is my test code:

; Create an ownerdrawn/colored button

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>


HotKeySet('{ESC}','Exit1')
Func Exit1()
    Exit
EndFunc


Example()

Func Example()
    Local Const $BS_OWNERDRAW = 0x0000000B
    Local $iButton = 0, $iButton2 = 0, $iMsg = 0

    GUICreate("My Ownerdrawn Created Button", 300, 200)

    $iButton = GUICtrlCreateButton("Test", 90, 50, 120, 30)
    ;GUICtrlSetStyle($iButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag


    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

    ;GUIRegisterMsg($WM_COMMAND, "") ;If i activate this line then MY_WM_COMMAND will not called when I presses on some button


    GUISetState(@SW_SHOW)

    While 1
        Sleep(1000)
;~         $iMsg = GUIGetMsg()

;~         Switch $iMsg
;~             Case $GUI_EVENT_CLOSE
;~                 ExitLoop

;~             Case $iButton
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button pressed")

;~             ;Case $iButton2
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button2 pressed")
;~         EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

; React on a button click
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam

    If $nID <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2
        ; Ownerdrawn buttons don't send something by pressing ENTER
        ; So IDOK - 1 comes up, now check for the control that has the current focus
        If $nID = 1 Then
            Local $hFocus = DllCall("user32.dll", "hwnd", "GetFocus")
            Local $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0])
            PostButtonClick($hWnd, $nCtrlID[0])
        Else
            MsgBox($MB_SYSTEMMODAL, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @CRLF & _
                    "MsgID" & @TAB & ":" & $Msg & @CRLF & _
                    "wParam" & @TAB & ":" & $wParam & @CRLF & _
                    "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd" & @TAB & ":" & $hCtrl)
        EndIf
        Return 0 ; Only workout clicking on the button
    EndIf
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

; RePost a WM_COMMAND message to a ctrl in a gui window
Func PostButtonClick($hWnd, $nCtrlID)
    DllCall("user32.dll", "int", "PostMessage", _
            "hwnd", $hWnd, _
            "int", $WM_COMMAND, _
            "int", BitAND($nCtrlID, 0x0000FFFF), _
            "hwnd", GUICtrlGetHandle($nCtrlID))
EndFunc   ;==>PostButtonClick

Question 2:
It appears that $GUI_EVENT_CLOSE is not working in this method
. What is the solution?

 

Thanks for helpers!

Share this post


Link to post
Share on other sites



gil900,

 

But I didn't saw in the help file how to unregister this function

You obviously did not look very hard: :P

 

Parameters

msgID : A Windows Message ID (see Appendix: Windows Message Codes).

function : The name of the user function to call when the message appears or an empty string "" to unregister a message.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Question 2:

It appears that $GUI_EVENT_CLOSE is not working in this method. What is the solution?

 

Do you mean the part that you have commented out is not working? :geek:


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

gil900,

 

You obviously did not look very hard: :P

 

Parameters

msgID : A Windows Message ID (see Appendix: Windows Message Codes).

function : The name of the user function to call when the message appears or an empty string "" to unregister a message.

M23

 

Oops.

I did not notice about it. :sweating:

what about $GUI_EVENT_CLOSE ? It not working with this method.

The function is not called when I click on the X button..

 

Do you mean the part that you have commented out is not working? :geek:

 

I did it on purpose .. I canceled those lines.

I want that MY_WM_COMMAND will be called when I click on X and it does not happen..

Edited by gil900

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I did it on purpose .. I canceled those lines.

I want that MY_WM_COMMAND will be called when I click on X and it does not happen..

 

Not trying to be rude by asking more questions, but why?

You haven't put any code into MY_WM_COMMAND to account for this anyway.

Listen to Melba, he's the guru. ;)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

gil900,

 

what about $GUI_EVENT_CLOSE ?

You need to register $WM_SYSCOMMAND to trap that: ;)

; Create an ownerdrawn/colored button

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>
#include <MenuConstants.au3>


HotKeySet('{ESC}','Exit1')
Func Exit1()
    Exit
EndFunc


Example()

Func Example()
    Local Const $BS_OWNERDRAW = 0x0000000B
    Local $iButton = 0, $iButton2 = 0, $iMsg = 0

    GUICreate("My Ownerdrawn Created Button", 300, 200)

    $iButton = GUICtrlCreateButton("Test", 90, 50, 120, 30)
    ;GUICtrlSetStyle($iButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag


    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
    GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

    ;GUIRegisterMsg($WM_COMMAND, "") ;If i activate this line then MY_WM_COMMAND will not called when I presses on some button


    GUISetState(@SW_SHOW)

    While 1
        Sleep(1000)
;~         $iMsg = GUIGetMsg()

;~         Switch $iMsg
;~             Case $GUI_EVENT_CLOSE
;~                 ExitLoop

;~             Case $iButton
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button pressed")

;~             ;Case $iButton2
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button2 pressed")
;~         EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)

    If $wParam = $SC_CLOSE Then
        ConsoleWrite("Close detected" & @CRLF)
    EndIf

EndFunc

; React on a button click
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam

    If $nID <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2
        ; Ownerdrawn buttons don't send something by pressing ENTER
        ; So IDOK - 1 comes up, now check for the control that has the current focus
        If $nID = 1 Then
            Local $hFocus = DllCall("user32.dll", "hwnd", "GetFocus")
            Local $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0])
            PostButtonClick($hWnd, $nCtrlID[0])
        Else
            MsgBox($MB_SYSTEMMODAL, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @CRLF & _
                    "MsgID" & @TAB & ":" & $Msg & @CRLF & _
                    "wParam" & @TAB & ":" & $wParam & @CRLF & _
                    "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd" & @TAB & ":" & $hCtrl)
        EndIf
        Return 0 ; Only workout clicking on the button
    EndIf
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

; RePost a WM_COMMAND message to a ctrl in a gui window
Func PostButtonClick($hWnd, $nCtrlID)
    DllCall("user32.dll", "int", "PostMessage", _
            "hwnd", $hWnd, _
            "int", $WM_COMMAND, _
            "int", BitAND($nCtrlID, 0x0000FFFF), _
            "hwnd", GUICtrlGetHandle($nCtrlID))
EndFunc   ;==>PostButtonClick
And do not put blocking functions inside message handlers - when the Help file says:

 

Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

it really means it! :ohmy:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The problem is that I do not clear enough because I'm saving words ..

I do not expect that function will close the script when I click on X because I did not worte the code needed for that -  which is what I need to do.

However, I can't start to write this code because the function is not triggered when I click on X.

the function is triggered when I click on any normal button. but this does not happen when I click on X.

The needed code in the function (and the function also) need to be triggered when X is pressed - while $hWnd = the gui that the X button is pressed and $Msg = $GUI_EVENT_CLOSE

 

This is what should happen when I click X. but it happen only when I click on custom buttons like GUICtrlCreateButton

Edited by gil900

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

gil900,

 

You need to register $WM_SYSCOMMAND to trap that: ;)

; Create an ownerdrawn/colored button

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>
#include <MenuConstants.au3>


HotKeySet('{ESC}','Exit1')
Func Exit1()
    Exit
EndFunc


Example()

Func Example()
    Local Const $BS_OWNERDRAW = 0x0000000B
    Local $iButton = 0, $iButton2 = 0, $iMsg = 0

    GUICreate("My Ownerdrawn Created Button", 300, 200)

    $iButton = GUICtrlCreateButton("Test", 90, 50, 120, 30)
    ;GUICtrlSetStyle($iButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag


    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
    GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

    ;GUIRegisterMsg($WM_COMMAND, "") ;If i activate this line then MY_WM_COMMAND will not called when I presses on some button


    GUISetState(@SW_SHOW)

    While 1
        Sleep(1000)
;~         $iMsg = GUIGetMsg()

;~         Switch $iMsg
;~             Case $GUI_EVENT_CLOSE
;~                 ExitLoop

;~             Case $iButton
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button pressed")

;~             ;Case $iButton2
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button2 pressed")
;~         EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)

    If $wParam = $SC_CLOSE Then
        ConsoleWrite("Close detected" & @CRLF)
    EndIf

EndFunc

; React on a button click
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam

    If $nID <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2
        ; Ownerdrawn buttons don't send something by pressing ENTER
        ; So IDOK - 1 comes up, now check for the control that has the current focus
        If $nID = 1 Then
            Local $hFocus = DllCall("user32.dll", "hwnd", "GetFocus")
            Local $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0])
            PostButtonClick($hWnd, $nCtrlID[0])
        Else
            MsgBox($MB_SYSTEMMODAL, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @CRLF & _
                    "MsgID" & @TAB & ":" & $Msg & @CRLF & _
                    "wParam" & @TAB & ":" & $wParam & @CRLF & _
                    "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd" & @TAB & ":" & $hCtrl)
        EndIf
        Return 0 ; Only workout clicking on the button
    EndIf
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

; RePost a WM_COMMAND message to a ctrl in a gui window
Func PostButtonClick($hWnd, $nCtrlID)
    DllCall("user32.dll", "int", "PostMessage", _
            "hwnd", $hWnd, _
            "int", $WM_COMMAND, _
            "int", BitAND($nCtrlID, 0x0000FFFF), _
            "hwnd", GUICtrlGetHandle($nCtrlID))
EndFunc   ;==>PostButtonClick
And do not put blocking functions inside message handlers - when the Help file says:

 

Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

it really means it! :ohmy:

M23

 

Thank you!

This is what I wanted to do!

I'll keep this useful thread for the future :)

Edited by gil900

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@Melba23

Can you please give me examples to the "unexpected behavior" ?

I did this test:

; Create an ownerdrawn/colored button

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>


HotKeySet('{ESC}','Exit1')
Func Exit1()
    Exit
EndFunc


;~ Local $BS_OWNERDRAW = 0x0000000B
Local $iButton = 0, $iButton2 = 0, $iMsg = 0

GUICreate("My Ownerdrawn Created Button", 300, 200)

$iButton = GUICtrlCreateButton("Test", 90, 50, 120, 30)
;GUICtrlSetStyle($iButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag


GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

;GUIRegisterMsg($WM_COMMAND, "") ;If i activate this line then MY_WM_COMMAND will not called when I presses on some button


GUISetState(@SW_SHOW)

While 1
    Sleep(1000)
;~         $iMsg = GUIGetMsg()

;~         Switch $iMsg
;~             Case $GUI_EVENT_CLOSE
;~                 ExitLoop

;~             Case $iButton
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button pressed")

;~             ;Case $iButton2
;~                 ; Normally should not run through cause of our MY_WM_COMMAND function
;~             ;    MsgBox($MB_SYSTEMMODAL, "Info", "Button2 pressed")
;~         EndSwitch
WEnd

; React on a button click
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Test1()
    Test2()
    Test3()

;~     Local $nNotifyCode = BitShift($wParam, 16)
;~     Local $nID = BitAND($wParam, 0x0000FFFF)
;~     Local $hCtrl = $lParam

;~     If $nID <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2
;~         ; Ownerdrawn buttons don't send something by pressing ENTER
;~         ; So IDOK - 1 comes up, now check for the control that has the current focus
;~         If $nID = 1 Then
;~             Local $hFocus = DllCall("user32.dll", "hwnd", "GetFocus")
;~             Local $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0])
;~             PostButtonClick($hWnd, $nCtrlID[0])
;~         Else
;~             MsgBox($MB_SYSTEMMODAL, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @CRLF & _
;~                     "MsgID" & @TAB & ":" & $Msg & @CRLF & _
;~                     "wParam" & @TAB & ":" & $wParam & @CRLF & _
;~                     "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF & _
;~                     "WM_COMMAND - Infos:" & @CRLF & _
;~                     "-----------------------------" & @CRLF & _
;~                     "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
;~                     "CtrlID" & @TAB & ":" & $nID & @CRLF & _
;~                     "CtrlHWnd" & @TAB & ":" & $hCtrl)
;~         EndIf
;~         Return 0 ; Only workout clicking on the button
;~     EndIf
;~     ; Proceed the default AutoIt3 internal message commands.
;~     ; You also can complete let the line out.
;~     ; !!! But only 'Return' (without any value) will not proceed
;~     ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

; RePost a WM_COMMAND message to a ctrl in a gui window
Func PostButtonClick($hWnd, $nCtrlID)
    DllCall("user32.dll", "int", "PostMessage", _
            "hwnd", $hWnd, _
            "int", $WM_COMMAND, _
            "int", BitAND($nCtrlID, 0x0000FFFF), _
            "hwnd", GUICtrlGetHandle($nCtrlID))
EndFunc   ;==>PostButtonClick


Func Test1()
    ConsoleWrite('Sleeping 10 sec..' & @CRLF)
    Sleep(10000)
    ConsoleWrite('End to sleep' & @CRLF)
EndFunc

Func Test2()
    MsgBox(0,'Test2','')
EndFunc

Func Test3()
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 153, 49, 192, 124)
    $Label1 = GUICtrlCreateLabel("Test 3", 56, 16, 34, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

        EndSwitch
    WEnd
EndFunc

And I see that the script does not respond in Test3() .
This is the
"unexpected behavior" ?

 

Any ideas how to solve this? so the script will continue to run correctly without un-register the MY_WM_COMMAND function?

Edited by gil900

Share this post


Link to post
Share on other sites

gil900,

Read the GUIRegisterMsg tutorial in the Wiki - that explains why. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

gil900,

Read the GUIRegisterMsg tutorial in the Wiki - that explains why. ;)

M23

Thanks

Problem solved :)

; Create an ownerdrawn/colored button

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>


HotKeySet('{ESC}','Exit1')
Func Exit1()
    Exit
EndFunc


;~ Local $BS_OWNERDRAW = 0x0000000B
Local $iButton = 0, $iButton2 = 0, $iMsg = 0

GUICreate("My Ownerdrawn Created Button", 300, 200)

$iButton = GUICtrlCreateButton("Test", 90, 50, 120, 30)

_AdlibCallStartStop(1) ; Start _AdlibCall

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")


GUISetState(@SW_SHOW)

While 1
    Sleep(1000)
WEnd

_AdlibCallStartStop(0) ; Stop _AdlibCall


; React on a button click
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    _AdlibCall('Test3')
;~  Test3()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND



Func Test3()
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 153, 49, 192, 124)
    $Label1 = GUICtrlCreateLabel("Test 3", 56, 16, 34, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete($Form1)
EndFunc

Func _AdlibCallStartStop($StartStop)
    Local Static $AlbGlobals
    If Not $AlbGlobals Then
        Global $g_AdlibCall_sFuncName
        $AlbGlobals = 1
    EndIf
    If $StartStop Then
        AdlibRegister('__AdlibCall')
    Else
        AdlibUnRegister('__AdlibCall')
    EndIf
EndFunc

Func _AdlibCall($sFuncName)
    $g_AdlibCall_sFuncName = $sFuncName
EndFunc


Func __AdlibCall()
    If Not $g_AdlibCall_sFuncName Then Return
    Call($g_AdlibCall_sFuncName)
    $g_AdlibCall_sFuncName = 0
EndFunc

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