StungStang Posted March 11, 2011 Share Posted March 11, 2011 (edited) Hi to all, i've an issue with the command GUIRegisterMsg() For example i've this script : expandcollapse popup#include <ButtonConstants.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiToolbar.au3> #include <ComboConstants.au3> #include <GUIComboBox.au3> Global Enum $idNew = 1000, $idOpen, $idSave Global $fComboChange = False $Form1 = GUICreate("Form1", 277, 259, 192, 124) $Label1 = GUICtrlCreateLabel("Write your text here:", 8, 40, 99, 17) $Combo1 = _GUICtrlComboBox_Create($Form1, "", 120, 40, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $ToolBar1 = _GUICtrlToolbar_Create($Form1, 0) $hDummy = GUICtrlCreateDummy() GUISetState(@SW_SHOW) _GUICtrlToolbar_AddBitmap ($Toolbar1, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton ($ToolBar1 , $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton ($ToolBar1, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton ($ToolBar1, $idSave, $STD_FILESAVE) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUIRegisterMsg($WM_COMMAND, "My_WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hDummy ; Read the code sent to the Dummy control $iCmdID = GUICtrlRead($hDummy) Switch $iCmdID Case 1000 MsgBox (0,"","New Button pressed!") Case 1001 MsgBox (0,"","Open Button pressed!") Case 1002 MsgBox (0,"","Save Button pressed!") EndSwitch EndSwitch If $fComboChange Then $fComboChange = False $sText = _GUICtrlComboBox_GetEditText($Combo1) If $sText <> "" Then TrayTip ("The new text is: ",$sText,5) EndIf EndIf WEnd Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $sText, $iItem $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) Switch $hWndFrom Case $Combo1 Switch $iCode Case $CBN_EDITCHANGE $fComboChange = True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Func My_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ; Check if CmdID is toolbar button Local $iCmdID = _WinAPI_LoWord($wParam) Switch $iCmdID Case $idNew To $idSave ; Send the CmdID to the Dummy control GUICtrlSendToDummy($hDummy, $iCmdID) EndSwitch EndFunc I've a Toolbar here, i use the My_WM_COMMAND function to know the pressed button... I've a combo box, i use it to put a text...i've a function that warn me if a "string" is write in the combo and if that change. Now if i try to registered this function toghether (_WM_COMMAND and My_WM_COMMAND) they dont work, if i try to register only one function the function work good. There are a metod to run the two functions together? Hi! <3 Edited March 11, 2011 by StungStang Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 11, 2011 Moderators Share Posted March 11, 2011 StungStang,You can only have one handler per message - as you have discovered. But you can have several "functions" within the same handler - like this. expandcollapse popup#include <ButtonConstants.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiToolbar.au3> #include <ComboConstants.au3> #include <GUIComboBox.au3> Global Enum $idNew = 1000, $idOpen, $idSave Global $fComboChange = False $Form1 = GUICreate("Form1", 277, 259, 192, 124) $Label1 = GUICtrlCreateLabel("Write your text here:", 8, 40, 99, 17) $Combo1 = _GUICtrlComboBox_Create($Form1, "", 120, 40, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $ToolBar1 = _GUICtrlToolbar_Create($Form1, 0) $hDummy = GUICtrlCreateDummy() GUISetState(@SW_SHOW) _GUICtrlToolbar_AddBitmap ($Toolbar1, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton ($ToolBar1 , $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton ($ToolBar1, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton ($ToolBar1, $idSave, $STD_FILESAVE) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hDummy ; Read the code sent to the Dummy control $iCmdID = GUICtrlRead($hDummy) Switch $iCmdID Case 1000 MsgBox (0,"","New Button pressed!") Case 1001 MsgBox (0,"","Open Button pressed!") Case 1002 MsgBox (0,"","Save Button pressed!") EndSwitch EndSwitch If $fComboChange Then $fComboChange = False $sText = _GUICtrlComboBox_GetEditText($Combo1) If $sText <> "" Then TrayTip ("The new text is: ",$sText,5) EndIf EndIf WEnd Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) Switch $hWndFrom Case $Combo1 Switch $iCode Case $CBN_EDITCHANGE $fComboChange = True EndSwitch EndSwitch ; Check if CmdID is toolbar button Local $iCmdID = _WinAPI_LoWord($iwParam) Switch $iCmdID Case $idNew To $idSave ; Send the CmdID to the Dummy control GUICtrlSendToDummy($hDummy, $iCmdID) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMANDAll clear? M23P.S. You do not need to declare function parameters as Local variables - they already are by default. 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now