Hawkwing Posted October 29, 2009 Share Posted October 29, 2009 I'm trying to write a script where I can double click on a listview item and have it run a function. I suppose I could just do guictrlsetonevent and then have it check for another click for about half a second, but I'd rather not since I want to be able to do other stuff at the same time. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 29, 2009 Share Posted October 29, 2009 You need to process "WM_NOTIFY". See the example for _GUICtrlListView_Create() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Hawkwing Posted October 30, 2009 Author Share Posted October 30, 2009 (edited) Well, uh, errm, do you have an example without the dll stuff? I have absolutely no idea how to do that stuff Edited October 30, 2009 by Hawkwing The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
Authenticity Posted October 30, 2009 Share Posted October 30, 2009 Look at the example of _GUICtrlListView_Create() in the help file. The WM_NOTIFY handler is quite big so the relevant parts to your needs in the handler are the initializations at the handler header before the switch case and the case $NM_DBLCLK. Link to comment Share on other sites More sharing options...
Hawkwing Posted October 31, 2009 Author Share Posted October 31, 2009 (edited) Thanks, I got it working now, but I have no idea why it works, so hopefully someone will explain a few of the things to me.Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ;~ Local $tBuffer $hWndListView = $listview If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ;~ Now I need the handle of the listviewitem EndSwitch EndSwitch EndFuncFirst, what exactly do the dll things do?And second, what does #forceref do?And third, how do I get the handle of the listviewitem I double click?Edit: Congrats on becoming an MVP Edited October 31, 2009 by Hawkwing The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
Authenticity Posted October 31, 2009 Share Posted October 31, 2009 (edited) 1) The dll structs are used for data passed between the system andthe your application. This message for example (WM_NOTIFY) will call your handler with $ilparam set to a pointer to a structure or nothing if it's not used as in some notifications. When you handle a notification you first need to read what data it sent on the notification such as $tagLVITEM which contains information about the list view item in question. You can read about it in MSDN with examples about many controls and their messages/structure/notifications/styles/etc.. (sorry for long boring...)2) Refer to this topic about #forceref.3) If you'll see the example of _GUICtrlListView_Create() you'll see that in this select case $ilParam contains a pointer to $tagNMITEMACTIVATE, go to the help file, search for this struct and you'll see all the data that you need. For example, the index of the item in question is held by the Index field of the struct so it should be something like:Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo ;~ Local $tBuffer $hWndListView = $listview If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) Local $iIndex = DllStructGetData($tInfo, "Index") Local $sItemText = _GUICtrlListView_GetItemText($listview, $iIndex) MsgBox(0x40, $iIndex, $sItemText) EndSwitch EndSwitch EndFuncEdit: Heh, thank you. Edited October 31, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Hawkwing Posted October 31, 2009 Author Share Posted October 31, 2009 Thanks! It works completely now, and I think I understand it. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. 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