Code: Select all
; Protected check boxes
EnableExplicit
Enumeration
#MainWindow
EndEnumeration
Enumeration
#LIG
#Protect
#Disable
EndEnumeration
Procedure myWndProc(hwnd, uMsg, wParam, lParam)
Protected Result
Result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_NOTIFY
Protected *nmhdr.NMHDR = lParam
If *nmhdr\hwndFrom=GadgetID(#LIG)
Select *nmhdr\code
Case #LVN_ITEMCHANGING
Protected *nmlv.NM_LISTVIEW = lParam
If *nmlv\uChanged=#LVIF_STATE
Select *nmlv\uNewState
Case 4096, 8192 ; try to uncheck/check list item
If GetGadgetState(#Protect); if #True -> protect
Result = #True
EndIf
EndSelect
EndIf
EndSelect
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
Procedure LIGEvents()
Debug "Still receive events while check boxes are protected"
EndProcedure
Procedure DisableLIG()
DisableGadget(#LIG, GetGadgetState(#Disable))
EndProcedure
; Example
Define Row
OpenWindow(#Mainwindow, 10, 10, 320, 240, "Protected Check Boxes", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#LIG, 10, 10, WindowWidth(#MainWindow)-20, WindowHeight(0)-60, "Column 1", 160,
#PB_ListIcon_CheckBoxes|#PB_ListIcon_FullRowSelect|#PB_ListIcon_MultiSelect|#PB_ListIcon_GridLines)
BindGadgetEvent(#LIG, @LIGEvents())
ButtonGadget(#Protect, WindowWidth(#MainWindow)/3-25, WindowHeight(#MainWindow)-40, 50, 24, "Protect",#PB_Button_Toggle)
ButtonGadget(#Disable, WindowWidth(#MainWindow)/3*2-25, WindowHeight(#MainWindow)-40, 50, 24, "Disable",#PB_Button_Toggle)
BindGadgetEvent(#Disable, @DisableLIG())
For Row = 1 To 50
AddGadgetItem(0,-1,"Row "+RSet(Str(Row),2,"0"))
Next
SetWindowCallback(@myWndProc())
Repeat
Until WaitWindowEvent()= #PB_Event_CloseWindow
What are the constant names for 4096 and 8192 (List-View Item States)?
They are not mentioned here:
https://msdn.microsoft.com/de-de/librar ... 85%29.aspx
But they should be found there according to here:
https://msdn.microsoft.com/de-de/librar ... 85%29.aspx