IonicWind Software

IWBasic => General Questions => Topic started by: Brian on May 31, 2012, 01:27:36 PM

Title: Listview checkboxes
Post by: Brian on May 31, 2012, 01:27:36 PM
Hi,

I see there are various threads on determining if a listview's checkboxes are checked or not,
by looping through the rows, but how do you actually set a single checkbox, on its own?

Brian
Title: Re: Listview checkboxes
Post by: billhsln on May 31, 2012, 01:50:58 PM
DEF d1:DIALOG
DEF D1_L1=100:INT  ' Listview
DEF t1:INT ' Index into Listiview, remember 0 based

' Set Flag on
SetCheckState(d1,D1_L1,t1,1)

SUB SetCheckState(win:DIALOG,cid:INT,index:INT,ticked:INT)
   DEF litem:LVITEM
   litem.mask=LVIF_STATE
   IF ticked THEN ticked = 0x2000 ELSE ticked = 0x1000
   litem.state=ticked
   litem.stateMask=LVIS_STATEIMAGEMASK
   SENDMESSAGE(win,LVM_SETITEMSTATE,index,litem,cid)
   RETURN
ENDSUB

SUB GetCheckState(win:DIALOG,cid:INT,index:INT),INT
DEF nState:INT
   'State image 1 is the unchecked box, and state image 2 is the checked box.
   'Setting the state image To zero removes the check box altogether.
   nState=(SENDMESSAGE(win,LVM_GETITEMSTATE,index,LVIS_STATEIMAGEMASK,cid))/4096
   RETURN (nState=2)
ENDSUB


To set off, change 1 to 0.

Bill
Title: Re: Listview checkboxes
Post by: Brian on May 31, 2012, 04:07:12 PM
Thanks, Bill - I'll give that a whirl

Brian