I've tried searching on Google and for other questions similar to mine, but all I get are results on how to use the LostFocus event or Deactivate, etc., but I'm under the impression each of these applies to controls on a form, or the actual form itself. What I need is a way to determine when my access database looses the focus entirely to another program in Windows, such as if I click on one of my access forms, MSAccess will have the focus. If I click on the start menu, it no longer has the focus, explorer has the focus. Or if I click on FireFox or Notepad, etc.
I realize I can put an onlostfocus code on every single one of my forms to check if access still has the focus and if not initiate some code, but that is very tedious, and I was hoping for a more general approach or maybe a built in function I was not aware of. I'm up for trying some API stuff too. I was reading here when I thought I could fiddle with WM_DectivateAPP, but the guy there ended up not using it so I didn't see any examples on how it would be used, nor can I find any elsewhere.
At the moment I have my database run by all popup forms, and the access application window and DB window are hidden, so that just the forms are visible, to help enforce the illusion that the database is a standalone app and not hosted by Access 2003. There is a large background form, a form across the top with custom titlebar and close button, beneath that a toolbar, and beneath that the nav form. My problem originally was that I would use the nav form or toolbar to open other database items, but at any given time if I clicked a different form or moved the form over a nav panel or toolbar etc. they would disappear or slip away. So I've instructed them not to be modal, but always to be "on top" of all other forms. The trouble is, when I click away from the database into another program, they are still there on top of that program too.
I want an Access.Application.LostFocus sort of event so that I can insert the "return to normal" procedure and apply it to all AlwaysOnTop forms, then continue with the switchover to the new programs.
Additionally, I would need an opposing Access.Application.GotFocus event to reinstate the alwaysontop procedure when the focus was returned to the accessdb.
Any ideas / suggestions?
Thanks in advance.
~Zach
P.S. -- I've already considered running an invisible form in the background to monitor the window with a timerevent for loss of activity, but that simply will not do, it takes up to much cpu to run a constant timer. Please avoid suggests similar to this. Thanks!