June 17, 2024, 09:24:57 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Listview checkboxes

Started by Brian, May 31, 2012, 01:27:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

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

billhsln

May 31, 2012, 01:50:58 PM #1 Last Edit: May 31, 2012, 01:52:46 PM by billhsln
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
When all else fails, get a bigger hammer.

Brian

Thanks, Bill - I'll give that a whirl

Brian