July 13, 2024, 06:59:03 PM

News:

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


TreeView Checkboxs

Started by LarryMc, January 24, 2007, 03:38:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

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?


LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Would also like to know how to change text color of indiviual items.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

January 25, 2007, 08:32:55 AM #2 Last Edit: January 25, 2007, 11:25:38 AM by Larry McCaughn
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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Could still use some help here   ;D
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

Ionic Wind Support Team

LarryMc

Thanks Paul,
that was the missing piece
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library