; English forum: http://www.purebasic.fr/english/viewtopic.php?t=9502&highlight= ; Author: Freak (updated for PB 4.00 by Andre) ; Date: 15. February 2004 ; OS: Windows ; Demo: No ; Problem: keine Debug-Ausgabe beim Anklicken der Spaltenüberschrift.... ; Detect column clicks in a ExplorerListGadget... ; Anklicken einer Spaltenüberschrift im ExplorerListGadget feststellen... ; Some notes: ; ----------- ; The Explorer type gadgets have a special parent window to process their ; messages. That's why such a message never makes it into the main ; callback. ; ; You have to subclass the imediate parent of the gadget in order To get ; such messages. ; ; As you see, it now only works with the explorerlistgadget. That's because ; the modified callback can't be set as WindowCallback() anymore, because ; of the "CallWindowProc_()" call at the end. ; ; So you have to set up another callback If you want both. ;- Window Constants ; Enumeration #Window_0 EndEnumeration ;- Gadget Constants ; Enumeration #ExplorerList_0 #ListIcon_0 EndEnumeration Global OldCallback ; <----------------------------- Procedure WinProc(hWnd,Msg,wParam,lParam) result = #PB_ProcessPureBasicEvents Select Msg Case #WM_NOTIFY *pnmh.NMHDR = lParam If *pnmh\hwndFrom = GadgetID(#ListIcon_0) Or GadgetID(#ExplorerList_0) Select *pnmh\code Case #LVN_COLUMNCLICK *pnmv.NMLISTVIEW = lParam column.l = *pnmv\iSubItem Debug "column clicked = " + Str(column) EndSelect EndIf EndSelect ProcedureReturn CallWindowProc_(OldCallback, hWnd, Msg, wParam, lParam) ; <----------------------------- EndProcedure Procedure Open_Window_0() If OpenWindow(#Window_0, 16, 56, 733, 300, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_TitleBar ) ; SetWindowCallback(@WinProc()) ; <----------------------------- If CreateGadgetList(WindowID(#Window_0)) ExplorerListGadget(#ExplorerList_0, 320, 5, 405, 290, "") ListIconGadget(#ListIcon_0, 5, 5, 305, 290, "Column0", 100) AddGadgetColumn(#ListIcon_0, 2, "Column1", 100) AddGadgetColumn(#ListIcon_0, 3, "Column2", 100) GadgetParent = FindWindowEx_(WindowID(#Window_0), 0,"ExplorerList_FakeParentClass", "ExplorerList_FakeParent") ; GadgetParent = GetParent_(GadgetID(#ExplorerList_0)) ; this will work with PB 3.9 OldCallback = SetWindowLong_(GadgetParent, #GWL_WNDPROC, @WinProc()) EndIf EndIf EndProcedure Open_Window_0() MessageRequester("Column clicks", "Click a column header for results.") Repeat Event = WaitWindowEvent() If Event = #PB_Event_Gadget GadgetID = EventGadget() If GadgetID = #ExplorerList_0 ElseIf GadgetID = #ListIcon_0 EndIf EndIf Until Event = #PB_Event_CloseWindow End ; IDE Options = PureBasic v4.02 (Windows - x86) ; CursorPosition = 1 ; Folding = - ; EnableXP