Search the Community
Showing results for tags '#windowsinternals'.
-
Hi all I suspect I am not the only AutoIT beginner who is confused by how WM_NOTIFY works. I've reviewed some of the code examples on the forum, checked out the MSDN entry here http://msdn.microsoft.com/en-us/library/windows/desktop/bb775583(v=vs.85).aspx , read a further MSDN article on the use of WM_NOTIFY here http://blogs.msdn.com/b/oldnewthing/archive/2009/08/21/9877791.aspx , but still am not getting it, except (perhaps) at a conceptual level. So, at a conceptual level I think what is happening is that a mouse click (for example) will update an in memory array structure called NMHDR with the handle to the window it was clicked in, the control id of the window it was clicked in, and the notification code which I assume will tell me whether right click, left click, double-click, etc. Back to AutoIT, in order to query the NMHDR array we create a user defined function using GUIRegisterMSG. What I understand this to mean is that when Windows sends a message via WM_NOTIFY, the user defined function will be called. Is that right? Even if I have everything above correct, I still don't understand most of the code I see on this forum as to how it works. Let me post a relatively random sample I pulled from here: Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $iIDFrom, $iCode, $tNMHDR, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom Case $listview Switch $iCode Case $NM_CLICK, $NM_RCLICK $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) If DllStructGetData($tInfo, "Item") > -1 Then _GUICtrlMenu_TrackPopupMenu($hMenu, $GUI) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY The first thing I don't understand is why the function has so many calling parameters. According to MSDN WM_NOTIFY only takes two parameters - the control id of the calling control, and a pointer to NMHDR. Secondly, what are the various structures that are being referenced in the three DLLStructCreate calls? They appear to be related to NMHDR but I'm not understanding the finer detail here. The function then goes on to deal with clicks in a listview only, and then is looking for a left mouse click or right mouse click (right?). The next two functions I don't get at all. Another DLLStructCreate which allows a struct read to ensure that the user has clicked on a menu subitem? The function then returns $GUI_RUNDEFMSG, which I don't see defined or updated anywhere in either the function or the overarching program. -------------- So, am I on the right track here, or am I way off beam? I would like to understand this a lot better so if someone could shed some detailed and clear instruction it would be very much appreciated. TIA Clark