Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can't set focus in CTreeCtrl

252 views
Skip to first unread message

Ralph Krausse

unread,
Nov 24, 1999, 3:00:00 AM11/24/99
to
I am trying to simply set a entry in my CTreeCtrl but can't seem to do it.
This is what I am trying


SetItemState(hCurrent,LVIS_FOCUSED|LVIS_SELECTED,LVIS_SELECTED);

This will highlight the entry I am interested in but not give it the focus
with in turn doesn't make it the
selected entry. Anyone?

Thanks
Ralph Krausse

David Lowndes

unread,
Nov 25, 1999, 3:00:00 AM11/25/99
to
> SetItemState(hCurrent,LVIS_FOCUSED|LVIS_SELECTED,LVIS_SELECTED);

Ralph,

Try:

SetItemState( hCurrent,
LVIS_FOCUSED|LVIS_SELECTED,
LVIS_FOCUSED|LVIS_SELECTED);

Dave
--
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Ralph Krausse

unread,
Nov 29, 1999, 3:00:00 AM11/29/99
to
Tried that but it didn't work. Anything else to try? What flags should I be
using when I add items?

Thanks Dave

David Lowndes <dav...@mvps.org> wrote in message
news:cfup3s4c1urmsmm7v...@4ax.com...

David Lowndes

unread,
Nov 30, 1999, 3:00:00 AM11/30/99
to
>Tried that but it didn't work.

Can you explain a little more about your particular situation where it
doesn't work?

Are you actually trying to give the control focus? Have you tried
using SetFocus (or GotoDlgCtrl if the control is in a dialog)?

Ralph Krausse

unread,
Dec 1, 1999, 3:00:00 AM12/1/99
to
Sure.. sorry... All I am trying to do is pragmatically set the selection and
highlight to a particular tree item.
I just dropped the control in my dialog, created a member variable to it,
and start additem tree items. A
user can enter in some information within a dialog and when the click ok and
the tree item is added (from
that dialog's information), I want that entry to be highlighted. I am not
sure if I am adding my items to the
tree with the correct flags.

thanks


David Lowndes <dav...@mvps.org> wrote in message

news:4d664s0ir7ir55aeh...@4ax.com...

David Lowndes

unread,
Dec 1, 1999, 3:00:00 AM12/1/99
to
>Sure.. sorry... All I am trying to do is pragmatically set the selection and
>highlight to a particular tree item.

If you add some items to the tree, then select one with the mouse to
highlight it, then move focus by selecting another control on the
dialog, is the selection in the tree control still visible? If it
isn't I think all you need is to set the TVS_SHOWSELALWAYS style (show
selection always, on the Styles tab in the dialog editor) for the
control.

0 new messages