Getting the last active form on Alt+Tab away from the app.

Using (or providing) components based on the "Win32" framework

Getting the last active form on Alt+Tab away from the app.

Postby norbertjurkiewicz84 on Fri Mar 20, 2015 4:05 pm

Has anyone figured out how to get the form/sub-form that is active and has focus when a user hits Alt+Tab to switch away form the interpreter. Windows will always set focus to the main application form when the user again switches back with Alt+Tab. It's an issue for keyboard heavy users that quickly alternate between applications. They hate having to click on a sub-form to continue working as they were.

I tried the ActivateApp event with WinAPI calls to get the active/focused form but either I'm doing something wrong or the interpreter has already lost form focus when Event callback is executed.
(It's the little things that make the difference :-)
User avatar
norbertjurkiewicz84
 
Posts: 62
Joined: Mon Nov 01, 2010 7:26 pm

Re: Getting the last active form on Alt+Tab away from the ap

Postby kai on Sun Mar 22, 2015 10:45 am

What about catching the LostFocus event? You can figure out whether it's about to go to another application. If that's the case you can use GetFocus to save a ref pointing to the control that has the focus at that very moment

Later, when you come back from elsewhere you can use this to re-establish the focus.
User avatar
kai
 
Posts: 137
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany

Re: Getting the last active form on Alt+Tab away from the ap

Postby norbertjurkiewicz84 on Mon Mar 23, 2015 2:24 pm

I thought about tracking each LostFocus event but CAS already uses many special instances of it to handle cleanup and auto-complete tasks. These tend to be specialized to what is happening. Rewriting those functions along with assigning a generic callback to all forms, without a LostFoucus event, will likely create a large number of GUI bugs.

I thought about having something intercepting the related Focus and Activate Windows Messages but I'd really like that to be a last resort. I hope to just be missing the obvious solution.
User avatar
norbertjurkiewicz84
 
Posts: 62
Joined: Mon Nov 01, 2010 7:26 pm


Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest