Class TPBCheckListBox (unit PBCheckLB)

Inherits from

TCustomListBox

Constructors


constructor Create(AOwner: TComponent);

constructor and destructor


Functions

destructor Destroy;

initialize the default values

procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);

Draw each item

Changed to use 3D drawing


function GetChecked(Index: Integer): Boolean;

check the range of Index

function GetState(Index: Integer): TCheckBoxState;

check the range of Index

procedure KeyDown(var Key: Word; Shift: TShiftState);

Handle

procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

Test if the mouse click hit the checkboxes

draw the item


procedure SetBmpChecked(Value: TBitmap);

if we use bitmaps, the min height must be the height of the bitmap +2 pixels

procedure SetBmpGrayed(Value: TBitmap);


procedure SetBmpUnchecked(Value: TBitmap);


procedure SetChecked(Index: Integer; const AChecked: Boolean);

Set and Get functions for the properties

check the range of Index


procedure SetFixedSize(Value: Boolean);


procedure SetFlat(Value: Boolean);

check the range of Index

procedure SetOffset(AnOffset: Integer);


procedure SetState(Index: Integer; const AState: TCheckBoxState);

check the range of Index

procedure CMFontChanged(var Message: TMessage);

Redraw the listbox if the font change

procedure CreateObject(Index: Integer);

Create an object associated with an item if it doesn't exist

free the bitmaps


procedure InvalidateCheck(Index:Integer);

Avoid flickering by redrawing only the change item

Properties

property Align :

pusblish the TListBox properties

property AllowGrayed : Boolean

new properties for the checkbox management

property BmpChecked : TBitmap


property BmpGrayed : TBitmap


property BmpUnchecked : TBitmap


property BorderStyle :


property Color :


property Columns :


property Ctl3D :


property DragCursor :


property DragMode :


property Enabled :


property ExtendedSelect :


property FixedSize : Boolean


property Flat : Boolean


property Font :


property IntegralHeight :


property ItemHeight :


property Items :


property MultiSelect :


property Offset : Integer


property ParentColor :


property ParentCtl3D :


property ParentFont :


property ParentShowHint :


property PopupMenu :


property ShowHint :


property Sorted :


property Style :


property TabOrder :


property TabWidth :


property Visible :


property Checked : Boolean

new properties for the checkbox management

property State : TCheckBoxState


Events

event OnClick :

pusblish the TListBox events

event OnDblClick :


event OnDragDrop :


event OnDragOver :


event OnDrawItem :


event OnEndDrag :


event OnEnter :


event OnExit :


event OnKeyDown :


event OnKeyPress :


event OnKeyUp :


event OnMeasureItem :


event OnMouseDown :


event OnMouseMove :


event OnMouseUp :


event OnStartDrag :


Variables

FAllowGrayed : Boolean;

Private declarations } { for the state of every element

FBmpChecked : TBitmap;

Bitmaps for the checkbox

FBmpGrayed : TBitmap;


FBmpUnchecked : TBitmap;


FFixedSize : Boolean;


FFlat : Boolean;


FOffset : Integer;

Offset between the listbox border and the bitmap } { and between the bitmap and the text

FStateList : TList;

Mantain a list of created objects so they can be freed when component is destroyed


Constructors


constructor Create(AOwner: TComponent);

constructor and destructor


Functions


destructor Destroy;

initialize the default values


procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);

Draw each item

Changed to use 3D drawing


function GetChecked(Index: Integer): Boolean;

check the range of Index


function GetState(Index: Integer): TCheckBoxState;

check the range of Index


procedure KeyDown(var Key: Word; Shift: TShiftState);

Handle


procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

Test if the mouse click hit the checkboxes

draw the item


procedure SetBmpChecked(Value: TBitmap);

if we use bitmaps, the min height must be the height of the bitmap +2 pixels


procedure SetBmpGrayed(Value: TBitmap);


procedure SetBmpUnchecked(Value: TBitmap);


procedure SetChecked(Index: Integer; const AChecked: Boolean);

Set and Get functions for the properties

check the range of Index


procedure SetFixedSize(Value: Boolean);


procedure SetFlat(Value: Boolean);

check the range of Index


procedure SetOffset(AnOffset: Integer);


procedure SetState(Index: Integer; const AState: TCheckBoxState);

check the range of Index


procedure CMFontChanged(var Message: TMessage);

Redraw the listbox if the font change


procedure CreateObject(Index: Integer);

Create an object associated with an item if it doesn't exist

free the bitmaps


procedure InvalidateCheck(Index:Integer);

Avoid flickering by redrawing only the change item


Properties


property Align :

pusblish the TListBox properties


property AllowGrayed : Boolean

new properties for the checkbox management


property BmpChecked : TBitmap


property BmpGrayed : TBitmap


property BmpUnchecked : TBitmap


property BorderStyle :


property Color :


property Columns :


property Ctl3D :


property DragCursor :


property DragMode :


property Enabled :


property ExtendedSelect :


property FixedSize : Boolean


property Flat : Boolean


property Font :


property IntegralHeight :


property ItemHeight :


property Items :


property MultiSelect :


property Offset : Integer


property ParentColor :


property ParentCtl3D :


property ParentFont :


property ParentShowHint :


property PopupMenu :


property ShowHint :


property Sorted :


property Style :


property TabOrder :


property TabWidth :


property Visible :


property Checked : Boolean

new properties for the checkbox management


property State : TCheckBoxState


Events


event OnClick :

pusblish the TListBox events


event OnDblClick :


event OnDragDrop :


event OnDragOver :


event OnDrawItem :


event OnEndDrag :


event OnEnter :


event OnExit :


event OnKeyDown :


event OnKeyPress :


event OnKeyUp :


event OnMeasureItem :


event OnMouseDown :


event OnMouseMove :


event OnMouseUp :


event OnStartDrag :


Variables


FAllowGrayed : Boolean;

Private declarations } { for the state of every element


FBmpChecked : TBitmap;

Bitmaps for the checkbox


FBmpGrayed : TBitmap;


FBmpUnchecked : TBitmap;


FFixedSize : Boolean;


FFlat : Boolean;


FOffset : Integer;

Offset between the listbox border and the bitmap } { and between the bitmap and the text


FStateList : TList;

Mantain a list of created objects so they can be freed when component is destroyed