Re: TreeView

new topic     » goto parent     » topic index » view thread      » older message » newer message

=A9koda wrote:

>can treeview have different icon for every item? i wanna do that but =
cant
get it to work.

As Wolfgang alluded, just add more icons using ILAddIcon().  =
Unfortunately,
I haven't gotten around to wrapping the treeview very elegantly yet =
(I've
got some better listview wrappers up at
http://members.xoom.com/matthewlewis/projects.html ).  Here's a little
explanation:

When I wrote the demo, I only used one icon (it's index was 0 as far as =
the
win32 API was concerned), so I didn't really need to select an image, =
and I
only specified the normal icon, and not the icon to be displayed when =
the
item is selected.  This will eventually be hidden from the user, but =
for
now, you need to worry about the mask value.  This tells windows what =
parts
of the TV_ITEM structure it needs to look at.  In my original demo, I =
hadn't
specified the TVIF_SELECTEDIMAGE, so it would default to the first icon
added (thanks to Wolfgang for bringing this to my attention).  =
Currently,
the programmer needs to keep track of icon indices.  I expect this to =
be
wrapped, again, similar to what I've done with the listview.

mask =3D or_all( {TVIF_IMAGE, TVIF_PARAM, TVIF_TEXT, TVIF_CHILDREN,
TVIF_SELECTEDIMAGE})

items[1] =3D insertTVItem( TV, mask, 0, 0, 0, "Test 1", 3, 2, 1, 1,=20
            TVI_ROOT, TVI_FIRST)

>also, how can i detect message that user has selected another item =
(with
mouse) in treeview?

You need to trap the WM_NOTIFY message that the treeview sends to it's
owner.  You'll need to create an onEvent() proc for the window that is =
the
owner of the treeview, and look for TVN_SELCHANGED within the NMHDR
structure (again, take a look at the listview demo I've put up).

You'll be pointed to an NM_TREEVIEW structure (which I haven't wrapped, =
yet,
either, but would look like this:

constant
NMTREEVIEW_hdr =3D allot( Long ),
NMTREEVIEW_action =3D allot( UInt ),
NMTREEVIEW_itemOld =3D allot( SIZEOF_TVITEM),
NMTREEVIEW_itemNew =3D allot( SIZEOF_TVITEM ),
NMTREEVIEW_ptDrag =3D allot( SIZEOF_POINT )

Note that itemOld itemNew and ptDrag are actually structures them =
selves.
To get the items in there, use them the structure names, and use the
structure elements of TV_ITEM's and a POINT structure to get the =
values.

The action member will return one of the following values, which =
specifies
how the item was selected, if you're interested:

TVC_BYKEYBOARD  By a key stroke
TVC_BYMOUSE     By a mouse click
TVC_UNKNOWN     Unknown

I don't think I included these values, but you should be able to find
definitions for them in winconst.ew, by Jacques Deschenes, which is in =
the
archives.  Hopefully, this will help you.  Let me know if you need any =
more
help.  I'd also appreciate if you (and everyone else) let me know how =
you're
using listviews and treeviews, so I can better wrap everything.

Right now I'm working on some drag and drop functionality.  It looks =
like
the only way to have windows do it is to define OLE objects, which =
looks to
be beyond my capabilities (if it's even possible in Eu).  But I think I =
see
a way to emulate it fairly easily.

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu