CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2011
    Posts
    60

    how do i set the focus after an alt+tab?

    Using mfc I have an application where I'm not allowed to use a mouse and alt+tab will be regularly used. Using alt+tab to come back to my application kills the focus in the view. Once my application comes back to the foreground how can I set the view as the focus? Thanks for taking the time to help.

    Greg

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: how do i set the focus after an alt+tab?

    You could try handling WM_ACTIVATE or WM_ACTIVATEAPP and setting the focus yourself. Where's the focus going if not to your view?

  3. #3
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: how do i set the focus after an alt+tab?

    I was going to say the same: if your view loses focus when you alt-tab twice there is probably something wrong with the rest of your code.

    Basically, the app should come back up without any focus changes at all.
    Nobody cares how it works as long as it works

  4. #4
    Join Date
    Mar 2011
    Posts
    60

    Re: how do i set the focus after an alt+tab?

    Yes... I'm sure there are lots of things wrong with the code as its been passed around for a couple years. To use the Wm-activate message would i just set the focus in the setactivewindow() function?

    Oh oh oh! The code had also been in the hands of the government so ya... Pretty bad code lol.

    OK I'm using OnSetFocus() to set the focus of the view but even though the view has the focus it still won't take any keyboard input...

    OK WM_ACTIVATE worked thank you very much. I thought OnSetFocus() would but I guess not.
    Last edited by Gregorina; May 23rd, 2014 at 01:02 PM.

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