IonicWind Software

IWBasic => GUI Central => Topic started by: LarryMc on January 24, 2007, 03:38:45 PM

Title: TreeView Checkboxs
Post by: LarryMc on January 24, 2007, 03:38:45 PM
Have the following TreeView example that has checkboxes on each node.

'by zerodog

def win:window
def run:INT
def handle,handle2,handle3:INT
CONST TVS_CHECKBOXES = 0x100

openwindow win,0,0,640,480,@CAPTION,0,"TreeView Demo",&winproc

CONTROL win,@TREEVIEW,"Tree 2",320,0,320,480,@BORDER|@TVSLINESATROOT|@TVSHASBUTTONS|@TVSHASLINES|TVS_CHECKBOXES,2
handle = tvInsertItem(win , 2, "One", 0)
handle2 = tvInsertItem(win , 2, "A",  handle)
handle3 = tvInsertItem(win , 2, "1A", handle2)
handle3 = tvInsertItem(win , 2, "2A", handle2)
handle3 = tvInsertItem(win , 2, "3A", handle2)
handle2 = tvInsertItem(win , 2, "B",  handle)
handle3 = tvInsertItem(win , 2, "1B", handle2)
handle3 = tvInsertItem(win , 2, "2B", handle2)


run=1
waituntil run=0
closewindow win
end

sub winproc
   select @CLASS
      CASE @IDCLOSEWINDOW
         run=0
   endselect
return
endsub


Can anyone provide me with the two Sendmessage codings to 1) get the state of a checkbox and 2) to set/reset a checkbox?


Title: Re: TreeView Checkboxs
Post by: LarryMc on January 24, 2007, 04:08:56 PM
Would also like to know how to change text color of indiviual items.
Title: Re: TreeView Checkboxs
Post by: LarryMc on January 25, 2007, 08:32:55 AM
Using the IB Pro source code for the treeview functions and what I could find on MSDN I was able to create the following routine which will give a 0 when the box is unchecked and a 1 when it is checked.

I admit it probably isn't the correct/best way to do it but it works.  It's the first time I've ever had any success trying to make sense out of the MSDN stuff! ;D

SUB tvGetItemState(win as WINDOW,id as UINT,handle as UINT),UINT
UINT hReturn:hReturn = 0
hControl = GetDlgItem(win.hwnd,id)
IF(hControl)
hReturn=(0x2000  & SendMessageA(hcontrol,TVM_GETITEMSTATE,handle,TVIS_STATEIMAGEMASK ))/0x2000
ENDIF
RETURN hReturn
ENDSUB


I even think I'll try to figure out how to make the color change. - NOT
Title: Re: TreeView Checkboxs
Post by: LarryMc on January 25, 2007, 12:48:35 PM
Tried to create TV set state and this didn't work.  I have no clue as what to try next.
global tvSetItemState
CONST TV_FIRST = 0x1100
CONST TVIF_STATE = 0x8
CONST TVIS_STATEIMAGEMASK = 0xF000
CONST TVM_SETITEMA = (TV_FIRST + 13)
CONST TVIF_STATE = 0x8
type TV_ITEM
    UINT       mask
    UINT     hItem
    UINT       state
    UINT       stateMask
    POINTER    pszText
    int        cchTextMax
    int        iImage
    int        iSelectedImage
    int        cChildren
    UINT       lParam
endtype
DECLARE IMPORT,GetDlgItem(hwnd as UINT,id as UINT),UINT
DECLARE IMPORT,GetModuleHandle ALIAS GetModuleHandleA(null as UINT),UINT
DECLARE IMPORT,SendMessageA(hwnd as UINT,uMsg as UINT,wParam as UINT,lParam as UINT),UINT
DECLARE IMPORT,ZeroMemory ALIAS RtlZeroMemory(pvoid as POINTER,length as INT),INT

SUB tvSetItemState(win as WINDOW,id as UINT,handle as UINT,nData as UINT),UINT
TV_ITEM tvi
hControl = GetDlgItem(win.hwnd,id)
POINTER p
UINT lParam
IF(hControl)
ZeroMemory(tvi,LEN(TV_ITEM))
tvi.stateMask = TVIS_STATEIMAGEMASK
tvi.state = nData
tvi.hItem = handle
p = tvi
lParam = p
RETURN SendMessageA(hcontrol,TVM_SETITEMA,0,lParam)
ENDIF
RETURN 0
ENDSUB
Title: Re: TreeView Checkboxs
Post by: LarryMc on January 26, 2007, 03:25:18 PM
Could still use some help here   ;D
Title: Re: TreeView Checkboxs
Post by: Ionic Wind Support Team on January 26, 2007, 09:49:00 PM
tvi.mask = TVIF_STATE
Title: Re: TreeView Checkboxs
Post by: LarryMc on January 26, 2007, 10:07:23 PM
Thanks Paul,
that was the missing piece