CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    85

    TreeControl bug?

    My Dialog has a tree control and an edit control, in
    a configuration window type setup.

    The problem I am having is that when I click on another
    item in the TreeControl, the KillFocus event for the edit
    does not fire before the TreeControl events start up.

    The order of messages seems to be:

    TVN_ONCLICK
    TVN_SELCHANGED
    EN_KILLFOCUS
    TVN_SETFOCUS

    This seems strange...shouldn't the TreeControl have to gain focus
    before it allows the user to perform any actions on it, like changing the selection?

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    Are you dealing with third party ActiveX control?
    If yes you would have to turn to an third party ActiveX control’s documentation regarding events that control fires.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: TreeControl bug?

    Originally posted by Thresher
    This seems strange...shouldn't the TreeControl have to gain focus
    before it allows the user to perform any actions on it, like changing the selection?
    No, not necessarily. The focus as such is only relevant for user interaction via the keyboard, so it is really up to the tree control whether it prefers to first process the selection change via the mouse and then send the notification message about the focus change. Also, note that we are not talking about the WM_KILLFOCUS and WM_SETFOCUS messages here, but about the notification messages EN_KILLFOCUS and TVN_SETFOCUS, which are sent back from the control to its parent window.

  4. #4
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    85

    Re: Re: TreeControl bug?

    Originally posted by gstercken
    No, not necessarily. The focus as such is only relevant for user interaction via the keyboard, so it is really up to the tree control whether it prefers to first process the selection change via the mouse and then send the notification message about the focus change. Also, note that we are not talking about the WM_KILLFOCUS and WM_SETFOCUS messages here, but about the notification messages EN_KILLFOCUS and TVN_SETFOCUS, which are sent back from the control to its parent window.
    So can you think of a work-around for this? Because the TreeControl TVN_ONCLICK is called before EN_KILLFOCUS for the Edit box I'm getting an undeseriable result by mixing different TreControl data with old EditBox data. Oh, and this is strictly MFC... no ActiveX or 3rd Party ActiveX here. THanks.

  5. #5
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Re: Re: TreeControl bug?

    Originally posted by Thresher
    So can you think of a work-around for this? Because the TreeControl TVN_ONCLICK is called before EN_KILLFOCUS for the Edit box I'm getting an undeseriable result by mixing different TreControl data with old EditBox data.
    What do you mean by old EditBox data? The data in an edit control doesn't depend on the EN_KILLFOCUS message being sent or not. Just use appropriate DDX member variables for your controls. When the tree control is clicked, call UpdateData(TRUE) and access the corresponding member variable to get the contents of the edit control. Besides that, you should check if TVN_ONCLICK is actually the message you want to handle for your case. For example, what happens when the user switches to the tree control by pressing the tab key? What if he uses the arrow keys to navigate the tree control? I suspect that TVN_SELCHANGING or TVN_SELCHANGED are probably more suited - but it really depends on your actual needs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured