shEiD Posted January 20, 2011 Share Posted January 20, 2011 (edited) A simple example (cannibalized the GUIRegisterMsg example):#include <WindowsConstants.au3> $Form1 = GUICreate("test", 190, 100, -1, -1) $Input1 = GUICtrlCreateInput("", 20, 20, 150, 21) $Button1 = GUICtrlCreateButton("button", 60, 60, 75, 25) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch WEnd Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) $hCtrl = $lParam ConsoleWrite("GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $Msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHwnd:" & $hCtrl & @LF & @LF) EndFunc ;==>MY_WM_COMMANDQuestions:How do I match the codes generated by MY_WM_COMMAND() to the codes the "Windows Message Codes" list in AutoIt's help file? I mean the codes results in the example do not match neither "$wParam" nor "Code" values..?martin points to msdn library for more info on notifications, but I can't find the list of codes anywhere on msdn. Sorry, I'm not used to msdn library. Let's say I go to Edit Control then to Notifications > EN_CHANGE - there is no code value provided there Where can I find a complete list of windows message codes?Thanks in advance. Edited January 20, 2011 by shEiD Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 20, 2011 Moderators Share Posted January 20, 2011 shEiD,How do I match the codes generated by MY_WM_COMMAND() to the codes the "Windows Message Codes" list in AutoIt's help file?You cannot. The codes in the Help file are the top-level messages of which WM_COMMAND is one - you can see it in the list as "WM_COMMAND 0x0111".What you get in the 4 handler parameters is information such as the handle of the GUI which sent the message, the specific sub-message that was sent, the handle and/or ControlID of the control that was actioned, etc... These can be simple values (as shown by the $hCtrl = $lParam line), set in the Hi/Lo parts of a doubleword (as shown by the $nNotifyCode and $nID lines) or even a pointer to a larger structure with many elements. You have to know how each top-level message treats its parameters to know how to get the details from them - MSDN is your friend here. Notifications > EN_CHANGE - there is no code value provided thereYes, one of many annoying aspects of MSDN. However, the AutoIt Devs have been very kind and most of the constants are in the relevant Constants.au3 #include file so you do not have to worry about the numeric value - for example, $EN_CHANGE is in EditConstants.au3 and is actually 0x300. I hope that helps. I have been toying for a while with producing something for the Wiki which sets out the more common messages and how to get the important values from the parameters - perhaps I will finally produce it this spring. But do not hold your breath! M23 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...
KaFu Posted January 20, 2011 Share Posted January 20, 2011 Good for endless hours of exploring and learning : MSDN: About Messages and Message Queues. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
shEiD Posted January 20, 2011 Author Share Posted January 20, 2011 (edited) Thank You for answers, I spent hours on this yesterday You cannot. The codes in the Help file are the top-level messages of which WM_COMMAND is one - you can see it in the list as "WM_COMMAND 0x0111". What you get in the 4 handler parameters is information such as the handle of the GUI which sent the message, the specific sub-message that was sent, the handle and/or ControlID of the control that was actioned, etc...I figured out that yesterday by trying to work out how some examples do it and how could I use them to do what I wanna do. You have to know how each top-level message treats its parameters to know how to get the details from them - MSDN is your friend here.When I could not find the codes in msdn it made me think that I'm not understanding this correctly. It's messed up, why would they not provide the codes? Or do they, and I just don't know how to find them? Yes, one of many annoying aspects of MSDN. However, the AutoIt Devs have been very kind and most of the constants are in the relevant Constants.au3 #include file so you do not have to worry about the numeric value - for example, $EN_CHANGE is in EditConstants.au3 and is actually 0x300.I found them in #includes, but it seems not all of them, that made me confused even more... I needed "on change" notification for Input control, but could not find it. Would $EN_CHANGE = 0x300 from EditConstants.au3 be ok to use with Input control? I hope that helps. I have been toying for a while with producing something for the Wiki which sets out the more common messages and how to get the important values from the parameters - perhaps I will finally produce it this spring. But do not hold your breath! Thank You, it helps so much, at least I know I'm not mad Explanation of this would be awesome, hope you'll be able to do it Good for endless hours of exploring and learning : MSDN: About Messages and Message Queues.Thanks, will try to read that, though I'm completely new to this, so it'll be long and hard I guess. Your description does not inspire confidence I needed to catch notifications for 2 things in my gui: 1. change in the Input control (data in another control reacts "live" on the text being entered in the Input control, 2. click on listview item, ie: on click I check if any items are selected, or there are no selections. Here is how I managed to acomplish these two things: GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") ; for input GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; for listview items Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $id = BitAND($wParam, 0x0000FFFF) If $id = 4 Or $id = 5 Then If $nNotifyCode = 768 Then ; code ConsoleWrite("input control changed" & @CRLF) EndIf EndIf EndFunc ;==>MY_WM_COMMAND Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom Case $ListView22 Switch $iCode Case $NM_CLICK Switch _GUICtrlListView_GetSelectedCount($ListView22) Case 0 ConsoleWrite("no items selected" & @CRLF) Case Else ConsoleWrite("items selected" & @CRLF) EndSwitch EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY Maybe there is a better way to do this? Edited January 20, 2011 by shEiD Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 20, 2011 Moderators Share Posted January 20, 2011 shEiD,Would $EN_CHANGE = 0x300 from EditConstants.au3 be ok to use with Input control?An Input is actually an Edit control forced into single line mode - so it is exactly what you need! And your message handlers look fine to me. Everyone has their own way of ordering the parameters - as long as you confirm the value of the ones you need to check the actual code you use is not that important. What is important is not staying in the handler any longer than you must - no blocking functions, or even very long ones. M23 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