CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2002
    Posts
    6

    How can I get previous windows focus ?

    Hello.

    I want to get previous window's focus.
    My program need to know prevoius focus of anoter windows.

    Thank you.

  2. #2
    Join Date
    May 2002
    Location
    Poland
    Posts
    48
    The window that previously had focus is passed to CWnd::OnSetFocus(). You can store its handle (not the pointer itself!) for later use.
    regards,
    MiMec

  3. #3
    Join Date
    Aug 2001
    Location
    North Bend, WA
    Posts
    1,947
    One way to do this is to have each control record its ID in a global variable in its OnKillFocus event handler. Then you can tell which control had the last.

    Another way is to implement a OnSetFocus handler. It gets a pointer to the previous controls CWnd as an argument .

  4. #4
    Join Date
    May 2002
    Posts
    6
    Hi

    Thank you.

    That helps me.

    One more add.. How can I get focus of previous window's component.
    For example If i did input edit box on windows or dialog box that has a lot of edit boxs, then How can I know Which has the previous focus ?

    Please help me ...

  5. #5
    Join Date
    Aug 2001
    Location
    North Bend, WA
    Posts
    1,947
    Its the one passed to you in OnSetFocus(CWnd *pWnd);

    pWnd is the previous control's window.

    pWnd->GetDlgCtrlID( ) ; // to get its ID, if that's what you need

  6. #6
    Join Date
    May 2002
    Posts
    6
    Thank you So much Bill.

    I really appreciate your help.

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