Link to home
Start Free TrialLog in
Avatar of gwosgood
gwosgoodFlag for United States of America

asked on

Indentifying when my application gets focus

Hello Experts,


     I need a way to determine when my application has recieved focus, either through clicking on the application in the taskbar or by clicking on the form window.  The form_GotFocus and _LoseFocus do not achieve this goal, since form_GotFocus only fires when all of the other applicable controls are disabled.  Is there a way, via API or not, to be able to do this?  I need to be able to open a file and input the contents when the application gets focus and in the interest of efficiency for the end-user, I would prefer them not to have to make an additional click.

Any and all help is greatly appreciated, this is a last-minute design change for a deadline project.


Gwosgood
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

You need to subclass and then trap the WM_ACTIVATE msg as in this PAQ:
https://www.experts-exchange.com/questions/20305542/Program-LostFocus-Ques.html
ASKER CERTIFIED SOLUTION
Avatar of iHadi
iHadi
Flag of Syrian Arab Republic image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gwosgood

ASKER

Thank you very much iHadi, a very simple solution, just the thing I was looking for.

One quick question though, what was the purpose of the command button?
You got me! I was writing another post that used a command button and it looks like you got a copy of my thoughts too. In this solution you do not need it only if you like clicking on empty coded buttons!