Jump to content

_GUICtrlToolbar_GetHotItem


Recommended Posts

Hello:

I am trying to use toolbar buttons to open the Folder dialog box. I have tried using value from $iItem to initiate the fileselectfolder. The problem starts after I close the folderdialog box. Clicking anywhere on the Toolbar even where there are no controls initiates the folderdialog box.

Could someone help me with a way out or an alternative to my method. I have posted the script from helpfile as it is.

Please help.

Regards

Ajit

#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

Global $hToolbar, $iMemo
Global $iItem ; Command identifier of the button associated with the notification.
Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp

_Main()

Func _Main()
    Local $hGUI, $aSize

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $hToolbar = _GUICtrlToolbar_Create ($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar)

    $iMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep ($hToolbar)
    _GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
    Local $tNMTOOLBAR, $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $idFrom = DllStructGetData($tNMHDR, "IDFrom")
    $code = DllStructGetData($tNMHDR, "Code")
    Switch $hwndFrom
        Case $hToolbar
            Switch $code
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem))
                    ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $iItem = $i_idNew
                    $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $i_idOld)
                    Else
                        Switch $i_idNew
                            Case $idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
Link to comment
Share on other sites

Hi:

I have posted my modified code. It is a single line to initiate fileselectfolder dialog box.

Please see that after closing the dialog box clicking anywhere on the Toolbar "line" initiates the fileselectfolder dialog box.

Ajit

#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

Global $hToolbar, $iMemo
Global $iItem ; Command identifier of the button associated with the notification.
Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp

_Main()

Func _Main()
    Local $hGUI, $aSize

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $hToolbar = _GUICtrlToolbar_Create ($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar)

    $iMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep ($hToolbar)
    _GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
    Local $tNMTOOLBAR, $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $idFrom = DllStructGetData($tNMHDR, "IDFrom")
    $code = DllStructGetData($tNMHDR, "Code")
    Switch $hwndFrom
        Case $hToolbar
            Switch $code
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem))
                    
                    ;;;;;;;;;;;;;;;;;;;;;;;;;;; MY CODE::::::::::::::::::::::::::::
                    
                    If $iItem = 1000 Then FileSelectFolder("Select Folder", "")
                    
                    ;;;;;;;;;;;;;;;;;;;;;;;;;; END OF My CODE ;;;;;;;;;;;;;;;;;
        ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $iItem = $i_idNew
                    $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $i_idOld)
                    Else
                        Switch $i_idNew
                            Case $idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
Link to comment
Share on other sites

  • Moderators

ajit,

Major problem with your code. Did you not read the Remarks section under GUIRegisterMsg? :P

"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 !!!"

FileSelectFolder is a blocking function - so it is hardly surprising that you are getting weird results after blocking the Windows message stream. Try using a flag like this - then you return quickly from the message handler and the problem goes away: :party:

#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

Global $hToolbar, $iMemo, $fFileSelect = False
Global $iItem ; Command identifier of the button associated with the notification.
Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp

_Main()

Func _Main()
    Local $hGUI, $aSize

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $hToolbar = _GUICtrlToolbar_Create ($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar)

    $iMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep ($hToolbar)
    _GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP)

    ; Loop until user exits
    Do

        ; Look for the flag <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        If $fFileSelect = True Then
            $fFileSelect = False
            FileSelectFolder("Select Folder", "")
        EndIf


    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
    Local $tNMTOOLBAR, $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $idFrom = DllStructGetData($tNMHDR, "IDFrom")
    $code = DllStructGetData($tNMHDR, "Code")
    Switch $hwndFrom
        Case $hToolbar
            Switch $code
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem))

                    ;;;;;;;;;;;;;;;;;;;;;;;;;;; MY CODE::::::::::::::::::::::::::::

                    If $iItem = 1000 Then $fFileSelect = True ; Set the flag <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

                    ;;;;;;;;;;;;;;;;;;;;;;;;;; END OF My CODE ;;;;;;;;;;;;;;;;;
        ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $iItem = $i_idNew
                    $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $i_idOld)
                    Else
                        Switch $i_idNew
                            Case $idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

Look for the <<<<<<<<<<<<<<< lines.

Ask if anything is unclear. :mellow:

M23

Edit: Typnig!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

ajit, I've modified your code:

#include <GuiToolbar.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

$Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

Global $hToolbar, $iMemo
Global $iItem ; Command identifier of the button associated with the notification.
Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp

_Main()

Func _Main()
    Local $hGUI, $aSize

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $hToolbar = _GUICtrlToolbar_Create ($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar)

    $iMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep ($hToolbar)
    _GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
    Local $tNMTOOLBAR, $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $idFrom = DllStructGetData($tNMHDR, "IDFrom")
    $code = DllStructGetData($tNMHDR, "Code")
    Switch $hwndFrom
        Case $hToolbar
            Switch $code
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    ;MemoWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem))

                    ;;;;;;;;;;;;;;;;;;;;;;;;;;; MY CODE::::::::::::::::::::::::::::

                    If $iItem = $idOpen Then FileSelectFolder("Select Folder", "")
                    If $iItem = $idNew Then MsgBox(0,"","Button New pressed")
                    If $iItem = $idSave Then MsgBox(0,"","Button Save pressed")
                    If $iItem = $idHelp Then MsgBox(0,"","Button Help pressed")

                    ;;;;;;;;;;;;;;;;;;;;;;;;;; END OF My CODE ;;;;;;;;;;;;;;;;;
        ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $iItem = $i_idNew
                    $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        ;MemoWrite("$HICF_LEAVING: " & $i_idOld)
                    Else
                        Switch $i_idNew
                            Case $idNew
                                ;----------------------------------------------------------------------------------------------
                                ;MemoWrite("$TBN_HOTITEMCHANGE: $idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $idOpen
                                ;----------------------------------------------------------------------------------------------
                                ;MemoWrite("$TBN_HOTITEMCHANGE: $idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $idSave
                                ;----------------------------------------------------------------------------------------------
                                ;MemoWrite("$TBN_HOTITEMCHANGE: $idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $idHelp
                                ;----------------------------------------------------------------------------------------------
                                ;MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY

Melba, could you explain this

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 !!!

more detailed? (Just for learning purposes... I don't quite understand it... Thank you in advance!) Edited by taietel
Link to comment
Share on other sites

  • Moderators

taietel,

Please read my post above - you still have a blocking function within the message handler! :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

 I know I have, that's why I've edited my post, asking for your help   Posted Image

I try to understand that... I'm not interested if the thing is working, but WHY!?

[edit] Handling errors <-- this is a thing that I need a lot of work also...

Edited by taietel
Link to comment
Share on other sites

  • Moderators

taietel,

This is an extract from the tutorial I wrote about GUIRegisterMsg in the Wiki:

"Windows works by sending messages to everything on the system, so that everything knows what is going on. By messages, I mean things like the $GUI_EVENT_CLOSE we look for when we exit a GUI - but the possible range is much, much wider; change of focus, change of state, mouseclicks, mousemoves, key presses, etc, etc, etc.

GUIRegisterMsg allows us to intercept certain of these messages as they are sent by the GUIs we have created, so we can see who sent what. So when you see a GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") line in a script, this translates as "Whenever a WM_COMMAND message is sent by my GUI, please intercept it and pass it through the MY_WM_COMMAND function in this script". The actual message title is denoted by the constant $WM_COMMAND which is stored in WindowsConstant.au3 include file. Of course, you can use other message types as well (such as $WM_NOTIFY) - and call your function whatever you wish!

[...]

Now, what about the use of a flag in the second example? Well, if you read the Help file for GUIRegisterMsg you will see the following:

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

Basically, if you spend too long in your message handling function, the rest of the system gets behind and becomes unstable. So you should get out of it as quickly as you can - and certainly never create anything that waits for user input. If you set a flag as in the second example you can then check for the flag in your While...WEnd loop, or via an Adlib function, and then run your long and complicated function without blocking the rest of the system."

Does that help?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

taietel,

Glad I could help. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...