************************************************** *-- Class: lstchkbox *-- ParentClass: listbox Define Class lstchkbox As ListBox Picture = "..\graphics\box.bmp" ColumnCount = 1 ColumnLines = .F. Name = "lstchkbox" Dimension aselected[1] *-- Checks and unchecks the box depending on whether or not the item is selected Procedure setlistitem With This If .ListIndex > 0 If .aselected[.ListIndex] .Picture[.ListIndex] = 'Box.bmp' .aselected[.ListIndex] = .F. Else .Picture[.ListIndex] = 'CheckBx.bmp' .aselected[.ListIndex] = .T. Endif Endif Endwith Endproc *-- Resets the aSelected array so none of the items are selected Procedure Reset With This *** clear all selections *** If other behavior is required by default, put it here and call this *** method from any place that the list box's contents must be reset .ListIndex = 0 Dimension .aselected[.ListCount] .aselected = .F. Endwith Endproc *-- Keeps correct pictures for selections when the list box is refreshed Procedure refreshlist Local lnItem With This For lnItem = 1 To .ListCount .Picture[ lnItem ] = Iif( .aselected[ lnItem ], 'CheckBx.bmp', 'Box.bmp' ) Endfor Endwith Endproc Procedure GotFocus ListBox::GotFocus() This.refreshlist() Nodefault Endproc Procedure KeyPress Lparameters nKeyCode, nShiftAltCtrl If nKeyCode = 32 Or nKeyCode = 13 This.setlistitem() Endif Endproc Procedure Click *** Clicking the mouse gives a lastkey() of 13 If Lastkey() = 13 This.setlistitem() Endif Endproc Procedure Init If DoDefault() This.Reset() Endif Endproc Enddefine