freak wrote:srod's way is the correct one if you want to just toggle the checked state (and preserve the others).
Yes, I understand now that it works bitwise.
However, the following small program does not behave as expected (tested with PB 4.31 and PB 4.40 Beta 3 on Windows XP).
Code: Select all
; Window Constants
Enumeration
#WinMain
EndEnumeration
; Gadget Constants
Enumeration
#ListIcon
#BtnCheck
#BtnSelect
#BtnUnCheck
#BtnUnSelect
EndEnumeration
Define Event
If OpenWindow(#WinMain, 100, 100, 220, 160, "Test") = 0
MessageRequester("Error", "OpenWindow() failed.")
End
EndIf
ListIconGadget(#ListIcon, 5, 5, 210, 70, "", 30, #PB_ListIcon_CheckBoxes | #PB_ListIcon_FullRowSelect)
AddGadgetColumn(#ListIcon, 1, "", 85)
AddGadgetColumn(#ListIcon, 2, "", 85)
AddGadgetItem(#ListIcon, -1, "" + #LF$ + "Mary" + #LF$ + "Meyer")
ButtonGadget(#BtnCheck, 10, 90, 90, 25, "Check item")
ButtonGadget(#BtnSelect, 120, 90, 90, 25, "Select item")
ButtonGadget(#BtnUnCheck, 10, 120, 90, 25, "Uncheck item")
ButtonGadget(#BtnUnSelect, 120, 120, 90, 25, "Unselect item")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #BtnCheck
SetGadgetItemState(#ListIcon,0, GetGadgetItemState(#ListIcon,0) | #PB_ListIcon_Checked)
Case #BtnSelect
SetGadgetItemState(#ListIcon,0, GetGadgetItemState(#ListIcon,0) | #PB_ListIcon_Selected)
Case #BtnUnCheck
SetGadgetItemState(#ListIcon,0, GetGadgetItemState(#ListIcon,0) & ~#PB_ListIcon_Checked)
Case #BtnUnSelect
SetGadgetItemState(#ListIcon,0, GetGadgetItemState(#ListIcon,0) & ~#PB_ListIcon_Selected)
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
There are problems concerning the selection:
Clicking at the button "Select item" has no effect.
When I have manually selected the item, clicking at the buttons "Check item" or "Unheck item" makes the selection disappear.
What am I doing wrong here?
TIA, Little John