ListIconGadget - capture header click {FIXED}
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
ListIconGadget - capture header click {FIXED}
When making a ListViewGadget, the header is clickakble, but no message arrives to EventGadget. I'm sure its a common question...looked in forums, but didnt find a solution. Is there a platform independent solution as the code I am writing needs to run on linux besides Windows.
Last edited by kinglestat on Thu Nov 29, 2007 8:56 pm, edited 1 time in total.
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
If it isn't listed as a supported EventType for the gadget, there isn't going to be a one-snippet-fits-all solution across platforms. I can give you code to do it in Windows if you can use that but you would have to write a CompilerIf block and find some Linux code to go in there with it, then you're set. But until the event goes native, that's the best there will be.
BERESHEIT
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
srod: ListViewGadget
netmaestro:
OK, I will do as you suggest if you will be so kind
cheers
netmaestro:
OK, I will do as you suggest if you will be so kind
cheers
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Re: ListViewGadget - capture header click
What is the header?kinglestat wrote:When making a ListViewGadget, the header is clickakble
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
Code: Select all
#result = 1
ListIconGadget(#result, 10, 10, 255, 305, "", 20, #PB_ListIcon_CheckBoxes|#PB_ListIcon_MultiSelect|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect )
AddGadgetColumn(#result,2,"Field 1",150)
AddGadgetColumn(#result,3,"Field 2 ",80)
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Ah the confusion is that a Windows ListView control (not gadget) equates to a PB LIstIcon whilst a Windows ListBox control equates to a PB ListView gadget.
Because you were talking about cross-platform then I took your use of a ListView to refer to a PB ListView (not a Windows one).
In PB terms then you are talking about a ListIcon.
Sorted.
There are plenty of examples in the forums about detecting header clicks (I've posted a couple myself). Search for ListIcon though or 'Header' etc.
Because you were talking about cross-platform then I took your use of a ListView to refer to a PB ListView (not a Windows one).
In PB terms then you are talking about a ListIcon.
Sorted.
There are plenty of examples in the forums about detecting header clicks (I've posted a couple myself). Search for ListIcon though or 'Header' etc.
I may look like a mule, but I'm not a complete ass.
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
My bad
I apologize for the confusion
I'm a bit tired
And now I realize why I didnt find anything
Thanks for the help, once again
I apologize for the confusion
I'm a bit tired
And now I realize why I didnt find anything
Thanks for the help, once again
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Here's how I'd do it:
Code: Select all
CompilerIf #PB_OS_Windows
#WM_CUSTOM_LVH_RBUTTONDOWN = #WM_APP + 1
#WM_CUSTOM_LVH_RBUTTONUP = #WM_APP + 2
#WM_CUSTOM_LVH_LBUTTONDOWN = #WM_APP + 3
#WM_CUSTOM_LVH_LBUTTONUP = #WM_APP + 4
Procedure HitTest(hwnd, lparam)
hti.hd_hittestinfo
hti\pt\x = lparam&$FFFF
hti\pt\y = lparam>>16
SendMessage_(hwnd, #HDM_HITTEST,0,@hti)
ProcedureReturn hti\iItem
EndProcedure
Procedure LV_HeaderCallBack(hwnd, msg, wparam, lparam)
Protected oldproc = GetProp_(hwnd, "oldproc")
Protected topwindow = GetProp_(hwnd, "topwindow")
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
RemoveProp_(hwnd, "topwindow")
Case #WM_RBUTTONUP
PostMessage_(topwindow,#WM_CUSTOM_LVH_RBUTTONUP,GetDlgCtrlID_(GetParent_(hwnd)),HitTest(hwnd,lparam))
Case #WM_RBUTTONDOWN
PostMessage_(topwindow,#WM_CUSTOM_LVH_RBUTTONDOWN,GetDlgCtrlID_(GetParent_(hwnd)),HitTest(hwnd,lparam))
Case #WM_LBUTTONDOWN
PostMessage_(topwindow,#WM_CUSTOM_LVH_LBUTTONDOWN,GetDlgCtrlID_(GetParent_(hwnd)),HitTest(hwnd,lparam))
Case #WM_LBUTTONUP
PostMessage_(topwindow,#WM_CUSTOM_LVH_LBUTTONUP,GetDlgCtrlID_(GetParent_(hwnd)),HitTest(hwnd,lparam))
EndSelect
ProcedureReturn CallWindowProc_(oldproc,hwnd,msg,wparam,lparam)
EndProcedure
CompilerElse
; Linux code
CompilerEndIf
OpenWindow(0,0,0,320,240,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ListIconGadget(33,0,0,320,240,"Column 0",100)
AddGadgetColumn(33,1,"Column 1",215)
CompilerIf #PB_OS_Windows
header = SendMessage_(GadgetID(33),#LVM_GETHEADER,0,0)
oldproc = SetWindowLong_(header,#GWL_WNDPROC, @LV_HeaderCallBack())
SetProp_(header, "oldproc", oldproc)
SetProp_(header, "topwindow", WindowID(0))
CompilerElse #PB_OS_Linux
; linux code
CompilerEndIf
Repeat
ev = WaitWindowEvent()
Select ev
CompilerIf #PB_OS_Windows
Case #WM_CUSTOM_LVH_LBUTTONDOWN
Debug "Left Button down for header item "+Str(EventlParam()) +" of ListIcon "+Str(EventwParam())
Case #WM_CUSTOM_LVH_LBUTTONUP
Debug "Left Button up for header item "+Str(EventlParam()) +" of ListIcon "+Str(EventwParam())
Case #WM_CUSTOM_LVH_RBUTTONDOWN
Debug "Right Button down for header item "+Str(EventlParam()) +" of ListIcon "+Str(EventwParam())
Case #WM_CUSTOM_LVH_RBUTTONUP
Debug "Right Button up for header item "+Str(EventlParam()) +" of ListIcon "+Str(EventwParam())
CompilerElse #PB_OS_Linux
; Linux code
CompilerEndIf
; more event tests
EndSelect
Until ev = #WM_CLOSE
Last edited by netmaestro on Fri Nov 30, 2007 4:30 am, edited 1 time in total.
BERESHEIT
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
thanks netmaestro
saved by the bell
I was tacking the wrong wind
I like the approach as its easier to make the diff linux/windows stuff
saved by the bell
I was tacking the wrong wind
I like the approach as its easier to make the diff linux/windows stuff
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada