ListIcon drag to select multiple rows
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
ListIcon drag to select multiple rows
ListIconGadget() Drag mouse to select multiple rows, as you can with a ListView?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: ListIcon drag to select multiple rows
3 days old, didja think we forgotcha?
Code: Select all
Procedure ListHandler(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, "oldproc")
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
Case #WM_MOUSEMOVE
If GetAsyncKeyState_(#VK_LBUTTON) & $8000
With lvh.LVHITTESTINFO
\pt\x = lparam&$FFFF
\pt\y = lparam>>16
EndWith
SendMessage_(GadgetID(0), #LVM_HITTEST, 0, @lvh)
SetGadgetItemState(GetDlgCtrlID_(hwnd), lvh\iItem, 1)
EndIf
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
If OpenWindow(0, 0, 0, 270, 240, "ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 10, 10, 250, 230,"col 0", 100,#PB_ListIcon_FullRowSelect|#PB_ListIcon_MultiSelect)
SetProp_(GadgetID(0), "oldproc", SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @ListHandler()))
AddGadgetColumn(0, 1,"col 1",165)
For a = 1 To 12
AddGadgetItem (0, -1, "Item " + Str(a)+Chr(10)+"More Item "+Str(a)) ; define listview content
Next
SetActiveGadget(0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
BERESHEIT
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ListIcon drag to select multiple rows
Woo, thanks netmaestro!
I forgot myself a long time ago, the PC is running on automatic..........
I forgot myself a long time ago, the PC is running on automatic..........
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ListIcon drag to select multiple rows
...darn - if I add #PB_ListIcon_CheckBoxes
....and either set to check or check and select:
That works nicely, but the check boxes now won't toggle with a left-click 
Code: Select all
IconGadget(0, 10, 10, 250, 230,"col 0", 100,#PB_ListIcon_FullRowSelect|#PB_ListIcon_MultiSelect|#PB_ListIcon_CheckBoxes)Code: Select all
SetGadgetItemState(GetDlgCtrlID_(hwnd), lvh\iItem, #PB_ListIcon_Checked|#PB_ListIcon_Selected)IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: ListIcon drag to select multiple rows
See if this is a bit closer to the goal, I'm assuming you want the drag to check the items as well as select them. If not, just remove the #PB_ListIcon_Checked flag from SetGadgetState:
Code: Select all
Procedure ListHandler(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, "oldproc")
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
Case #WM_MOUSEMOVE
If GetAsyncKeyState_(#VK_LBUTTON) & $8000
With lvh.LVHITTESTINFO
\pt\x = lparam&$FFFF
\pt\y = lparam>>16
EndWith
SendMessage_(GadgetID(0), #LVM_HITTEST, 0, @lvh)
If Not lvh\flags & #LVHT_ONITEMSTATEICON
SetGadgetItemState(GetDlgCtrlID_(hwnd), lvh\iItem, #PB_ListIcon_Checked|#PB_ListIcon_Selected)
EndIf
EndIf
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
If OpenWindow(0, 0, 0, 270, 240, "ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 10, 10, 250, 230,"col 0", 100,#PB_ListIcon_FullRowSelect|#PB_ListIcon_MultiSelect|#PB_ListIcon_CheckBoxes)
SetProp_(GadgetID(0), "oldproc", SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @ListHandler()))
AddGadgetColumn(0, 1,"col 1",165)
For a = 1 To 12
AddGadgetItem (0, -1, "Item " + Str(a)+Chr(10)+"More Item "+Str(a)) ; define listview content
Next
SetActiveGadget(0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIfBERESHEIT
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: ListIcon drag to select multiple rows
Hi netmaestro
I only just noticed this response (wasn't expecting one) - it's a beautiful thing, thank you!
I only just noticed this response (wasn't expecting one) - it's a beautiful thing, thank you!
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: ListIcon drag to select multiple rows
It's interesting that it checks the boxes if you drag & select -- but if you then unselect & drag/select it does not uncheck the boxes..
