March 29, 2024, 01:11:46 AM

News:

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


Treev iew

Started by Brian, July 11, 2019, 11:30:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

Hi,
I am loading a Treeview with drives and folders. It already jumps to the default folder, and gets a handle to the folder's path. What I want is for the Treeview to jump to the folder, and show it highlighted
I think that you use TVM_SELECTITEM, but I can't get it work at all. I am sure that I have seen it before, but the code is eluding me
Brian

fasecero

Brian,

If TVM_SELECTITEM has been successful the treeview probably needs the focus to show the highlighted item. Try calling SETFOCUS(win, treeviewID) before or after the TVM_SELECTITEM call. Also @TVSSHOWSELALWAYS style might come in handy.

Brian

Thanks, Fasecero,
Don't know if I have got the call right, but I tried it all ways with SETFOCUS. I know that it is setting the right folder, and I am getting a handle back with bf=SENDMESSAGE(win,BFF_GETPATH,bf,Paths,BFF) - it is a custom control

I am using the call SENDMESSAGE win,TVM_SELECTITEM,0,bf,BFF - I hope this is right?

Brian

fasecero

This sample seems to be working fine, is there any reason you are using TVM_SELECTITEM over tvSelectItem


CONST TREEVIEW_1 = 1
WINDOW w1
OPENWINDOW w1,0,0,600,400,@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&w1_handler

INT tvStyles = @TVSHASBUTTONS | @TVSHASLINES | @TVSLINESATROOT | @TVSSHOWSELALWAYS | @BORDER
CONTROL w1,@TREEVIEW,"Static",29,17,314,258,tvStyles,TREEVIEW_1

OnInit()

' main loop
WAITUNTIL w1 = 0
END
 
' window procedure
SUB w1_handler(), INT
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
CLOSEWINDOW w1
ENDSELECT

RETURN 0
ENDSUB

SUB OnInit()
INT root = tvInsertItem(w1, TREEVIEW_1, "Root", 0)
INT first  = tvInsertItem(w1, TREEVIEW_1, "First", root)
INT second = tvInsertItem(w1, TREEVIEW_1, "Second", root)
tvSelectItem(w1, TREEVIEW_1, first) ' first should always be selected due to @TVSSHOWSELALWAYS
ENDSUB