ListIconGadget & checkbox states
ListIconGadget & checkbox states
Hi
I’ve been fiddling a bit with ListIconGadget, and realized there doesn’t appear to be a proper implementation for PB commands to detect fully the state of a checkbox for when an item becomes checked or unchecked. And this is a problem when clicking directly on a ListIconGadget checkboxes, if I were to select a line and not try to change a line checkbox state, correct line information returns that allows me to retrieve the actual state of that line checkbox, but if there is no selection in ListIconGadget and you check or uncheck directly on a checkbox there is a problem and if there is a selection in a ListIconGadget and you check or uncheck directly a checkbox which is other-than the selected line then that is a problem in addition.
Now I could simply read every line in a ListIconGadget, and check its checkbox state but I were trying to avoid this for large list of items by making a cache of all which gets changed from the original state (for increase speed).
I’ve been fiddling a bit with ListIconGadget, and realized there doesn’t appear to be a proper implementation for PB commands to detect fully the state of a checkbox for when an item becomes checked or unchecked. And this is a problem when clicking directly on a ListIconGadget checkboxes, if I were to select a line and not try to change a line checkbox state, correct line information returns that allows me to retrieve the actual state of that line checkbox, but if there is no selection in ListIconGadget and you check or uncheck directly on a checkbox there is a problem and if there is a selection in a ListIconGadget and you check or uncheck directly a checkbox which is other-than the selected line then that is a problem in addition.
Now I could simply read every line in a ListIconGadget, and check its checkbox state but I were trying to avoid this for large list of items by making a cache of all which gets changed from the original state (for increase speed).
See if this helps...
*Edited to fix code*
Code: Select all
#LVN_ITEMCHANGED = #LVN_FIRST-1
#MyWindow = 0
#MyGadget = 1
Procedure myWindowCallback(hWnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
Select *pnmhdr\code
Case #LVN_ITEMCHANGED
*lvChange.NMLISTVIEW = lParam
Debug *lvChange\uNewState >>12 &$FFFF
;--> Read the State image mask value ( 1 = un-checked 2 = checked
Select *lvChange\uNewState >>12 &$FFFF
Case 1
StatusBarText(0, 0, "Item " + Str(*lvChange\iItem) + " has been un-checked")
Case 2
StatusBarText(0, 0, "Item " + Str(*lvChange\iItem) + " has been checked")
EndSelect
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(#MyWindow, 100, 100, 350, 140, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "ListIcon Test") And CreateGadgetList(WindowID())
CreateStatusBar(0, WindowID())
ListIconGadget(#MyGadget, 5, 5, 340, 110, "Name", 100, #PB_ListIcon_CheckBoxes | #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#MyGadget, 1, "Address", 250)
AddGadgetItem(#MyGadget, -1, "Harry Rannit" + Chr(10) + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(#MyGadget, -1, "Ginger Brokeit" + Chr(10) + "130 PureBasic Road, BigTown, CodeCity")
SetWindowCallback(@myWindowCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
Last edited by Sparkie on Sun Mar 20, 2005 4:14 am, edited 1 time in total.
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
> See if this helps
Your code has a bug somewhere, Sparkie... run it and do this:
(1) Click Ginger's name (not her checkbox).
(2) Click Harry's checkbox.
(3) Click Ginger's checkbox.
(4) Repeat (3) and Ginger's state doesn't change anymore...

(A native command to get the checkbox state of a ListIconGadget item would be nice).
Your code has a bug somewhere, Sparkie... run it and do this:
(1) Click Ginger's name (not her checkbox).
(2) Click Harry's checkbox.
(3) Click Ginger's checkbox.
(4) Repeat (3) and Ginger's state doesn't change anymore...

(A native command to get the checkbox state of a ListIconGadget item would be nice).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Dear team, do you think it's possible for the GetGadgetState() command to return the ListIconGadget item when a checkbox is checked, like in Sparkie's example? At the moment the command only returns which item is selected, and takes no consideration if a checkbox is actioned. I think a checkbox action should override any item selection so that GetGadgetState() shows which item had its checkbox checked.
Re:
+1UserOfPure wrote:Dear team, do you think it's possible for the GetGadgetState() command to return the ListIconGadget item when a checkbox is checked, like in Sparkie's example? At the moment the command only returns which item is selected, and takes no consideration if a checkbox is actioned. I think a checkbox action should override any item selection so that GetGadgetState() shows which item had its checkbox checked.
Thanks.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
Re: ListIconGadget & checkbox states
Isn't this already implemented?
If the above line is selected and ticked then do stuff.
Code: Select all
If GetGadgetItemState(#List,1) & #PB_ListIcon_Checked
do stuff
Endif
----
R Tape loading error, 0:1
R Tape loading error, 0:1
Re: ListIconGadget & checkbox states
No.em_uk wrote:Isn't this already implemented?
If the above line is selected and ticked then do stuff.Code: Select all
If GetGadgetItemState(#List,1) & #PB_ListIcon_Checked do stuff Endif
For GetGadgetItemState you need the item index to know from which item you wont the state, and that isn't 'send' when the check is placed.
(with api's this is possible...)
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.