If I create a ListIconGadget with the #PB_ListIcon_CheckBoxes flag, is there
a way to have some items without a checkbox? I only want some to have a
checkbox, rather than all.
ListIconGadget with checkboxes
ListIconGadget with checkboxes
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.
There might be a better way, but these 2 methods work for me on WinXPhome with PB3.92.
Remove ListIconGadget checkboxes in WaitWindowEvent()
Remove ListIconGadget checkboxes with SetWindowCallback()
Remove ListIconGadget checkboxes in WaitWindowEvent()
Code: Select all
If OpenWindow(0, 0, 0, 270, 150, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "ListIconGadget") And CreateGadgetList(WindowID(0))
ListIconGadget(0, 10, 10, 250, 125, "Testing", 200, #PB_ListIcon_CheckBoxes)
For a = 0 To 12
addtext$ = "Item index #" + Str(a) + " in the ListIconGadget"
AddGadgetItem(0, -1, addtext$)
Next
; --> Remove checkboxes for items 2, 3, 4
For i = 2 To 4
lv.LV_ITEM\mask = #LVIF_STATE
lv\iItem = i
lv\state = 0 << 12
lv\stateMask = #LVIS_STATEIMAGEMASK
SendMessage_(GadgetID(0), #LVM_SETITEMSTATE, i, lv)
Next
Repeat
event = WaitWindowEvent()
Select event
Case #PB_EventGadget
Select EventGadgetID()
Case 0
; --> Remove checkboxes for items 2, 3, 4
For i = 2 To 4
SendMessage_(GadgetID(0), #LVM_SETITEMSTATE, i, lv)
Next
EndSelect
EndSelect
Until event =# PB_Event_CloseWindow
EndIf
End
Code: Select all
Procedure myWindowCallback(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*nmNMHDR.NMHDR = lparam
If *nmNMHDR\code = #LVN_ITEMCHANGED
*lvm.NMLISTVIEW = *nmNMHDR
; --> Remove checkboxes for items 2, 3, 4
If *lvm\iItem > 1 And *lvm\iItem < 5
lv.LV_ITEM\mask = #LVIF_STATE
lv\state = 0 << 12
lv\stateMask = #LVIS_STATEIMAGEMASK
SendMessage_(GadgetID(0), #LVM_SETITEMSTATE, *lvm\iItem, lv)
EndIf
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 270, 150, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "ListIconGadget") And CreateGadgetList(WindowID(0))
SetWindowCallback(@myWindowCallback())
ListIconGadget(0, 10, 10, 250, 125, "Testing", 200, #PB_ListIcon_CheckBoxes)
For a = 0 To 12
addtext$ = "Item index #" + Str(a) + " in the ListIconGadget"
AddGadgetItem(0, -1, addtext$)
Next
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
Thanks guys, glad to hear it works for you. 
As for using x's in place of checkmarks, this seems to work ok. I'm not very good with 2DDrawing so I'm sure this can be optimized. If nothing else, it gives you a start in the right direction

As for using x's in place of checkmarks, this seems to work ok. I'm not very good with 2DDrawing so I'm sure this can be optimized. If nothing else, it gives you a start in the right direction

Code: Select all
If OpenWindow(0, 0, 0, 270, 150, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "ListIconGadget") And CreateGadgetList(WindowID(0))
ListIconGadget(0, 10, 10, 250, 125, "Testing", 200, #PB_ListIcon_CheckBoxes)
For a = 0 To 12
addtext$ = "Item index #" + Str(a) + " in the ListIconGadget"
AddGadgetItem(0, -1, addtext$)
Next
; --> Create our checked checkbox image with red x
itemChecked = CreateImage(0, 16, 16)
StartDrawing(ImageOutput())
Box(0, 0, 16, 16, RGB(255, 255, 255))
Box(1, 1, 14, 14, RGB(0, 0, 0))
Box(3, 3, 10, 10, RGB(255, 255, 255))
; --> red line top left to bottom right
LineXY(4, 4, 11, 11, RGB(255, 0, 0))
LineXY(5, 4, 11, 10, RGB(255, 0, 0))
LineXY(4, 5, 10, 11, RGB(255, 0, 0))
; --> red line bottom left to top right
LineXY(4, 11, 11, 4, RGB(255, 0, 0))
LineXY(4, 10, 10, 4, RGB(255, 0, 0))
LineXY(5, 11, 11, 5, RGB(255, 0, 0))
StopDrawing()
; --> Create our un-checked checkbox image with no red x
itemUnchecked = CreateImage(1, 16, 16)
StartDrawing(ImageOutput())
Box(0, 0, 16, 16, RGB(255, 255, 255))
Box(1, 1, 14, 14, RGB(0, 0, 0))
Box(3, 3, 10, 10, RGB(255, 255, 255))
StopDrawing()
; --> Create our new state imagelist for ListIconGadget
stateImageList= ImageList_Create_(16, 16, #ILC_COLOR32, 0, 2)
ImageList_Add_(stateImageList, itemUnchecked, 0)
ImageList_Add_(stateImageList, itemChecked, 0)
SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_STATE, stateImageList)
; --> Remove checkboxes for items 2, 3, 4
For i = 2 To 4
lv.LV_ITEM\mask = #LVIF_STATE
lv\iItem = i
lv\state = 0 << 12
lv\stateMask = #LVIS_STATEIMAGEMASK
SendMessage_(GadgetID(0), #LVM_SETITEMSTATE, i, lv)
Next
Repeat
event = WaitWindowEvent()
Select event
Case #PB_EventGadget
Select EventGadgetID()
Case 0
; --> Remove checkboxes for items 2, 3, 4
For i = 2 To 4
SendMessage_(GadgetID(0), #LVM_SETITEMSTATE, i, lv)
Next
EndSelect
EndSelect
Until event =# PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
Thanks Sparkie!Sparkie wrote: it gives you a start in the right direction![]()
I played with a bit and ende up with this...
Code: Select all
FontID1 = LoadFont(3, "Arial", 8, #PB_Font_Bold)
------------
; --> Create our checked checkbox image with an X
itemChecked = CreateImage(0, 16, 16)
StartDrawing(ImageOutput())
Box(1, 1, 14, 14, RGB(255, 255, 255))
DrawingFont(FontID1) ; Select a drawing font
FrontColor(255, 0, 0) ; Choose the color of the X here
Locate(5, 1) ; Locate the cursor and
DrawText("X") ; draw the X using the chosen drawing font
StopDrawing()
; --> Create our un-checked checkbox image
itemUnchecked = CreateImage(1, 16, 16)
StartDrawing(ImageOutput())
Box(1, 1, 14, 14, RGB(255, 255, 255))
StopDrawing()
That will get some users off my back as soon as I can implement this in
three programs.
Tnanks for your suggestions and ideas,
Terry