[AccessD] Access Form Outside The Application Container - Mak ing It Active Programmatically

DWUTKA at marlow.com DWUTKA at marlow.com
Wed Feb 25 15:36:37 CST 2004


Welcome to the wonderful world of MS Access forms.  Access forms seem like
normal windows, but they are far from it.

The only way to explain the odd behavior, is to just point out the fact that
Access forms AREN'T normal windows.  Let me give you an example of what I
mean.  Take ANY other window on your computer.  Something from VB, or any
application where you have command buttons, textboxes, etc.  Now, look at
the hWnd of the window (there are dozens of utilities out there to do this,
or I can send you one I made in VB.  More importantly, look at the 'child
windows' of the form/window.  You'll find that every control is it's own
individual window.  Now look at an Access form.  It has ONE 'control' child
window, which just changes from control to control.  So when a control isn't
active, it's really just 'drawn' on the Access form. 

It is VERY odd behavior.

Back to your actual system design, may I make a little suggestion?  I think
I see where you are going, and I think I have a 'slicker' approach.  Instead
of minimizing Access, why not HIDE access, and put a form into the system
tray.  That way, you have a presence (with an icon in your system tray),
Access is still running, and when you want to display a 'message', just use
a msgbox.  I have an example of the system tray process in my MiniCalendar.
(On my website).  Open it, run the 'cycle' mode, and press the 'sleep'
button.  It will put the Minicalendar into the system tray, as an icon.

A little warning.  That's an Access 97 db, and it works fine in 97.
However, to 'subclass' the form to the system tray, it needs to use the
AddressOf function, which Ken Getz wrote a 'cheat' for in 97.  In A2k and
up, AddressOf is actually available, so my sample won't work in A2k (not the
system tray portion).  So if you are using A2k or higher, let me know, I'll
whip up an example for you.

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of A.D.Tejpal
Sent: Tuesday, February 24, 2004 11:27 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Access Form Outside The Application Container -
Making It Active Programmatically


Drew,

    Your demo has been very helpful in finding a solution. Certain
peculiarities encountered in the process are mentioned below - in case you
could throw some light.

    The objective is to have the access application in standby mode
(minimized state), with a timer form active. When certain conditions are
met, this form causes another form (meant to convey an Alert) to pop up onto
the desktop. This pop-up form is required to have the focus on its OK button
so that the user is not compelled to use the mouse for dismissing the form.

    (a) The following code in Timer Form's module achieves the desired
results -
        ShowWindow Application.hWndAccessApp, _
                                            SW_SHOWMINIMIZED  ' (A)
        DoCmd.OpenForm "frmAlert", acNormal
        FrmHDL = Forms("frmAlert").hwnd
        ShowWindow FrmHDL, SW_SHOWNORMAL

    (b) However, if the API call at (A) is replaced by the following line,
the pop-up form gets displayed without having a focus (adding the statement
Forms("frmAlert").SetFocus at the end of (a) does not appear to be
effective) -
        DoCmd.RunCommand acCmdAppMinimize
        

    (c) Again, if (A) is retained, but the timer form is sought to be closed
by placing the following line at the very end of (a), the pop-up form
appears without focus -
        DoCmd.Close acForm, Me.Name

    I shall be thankful if the reason for behaviour outlined at (b) & (c)
above could be explained.

Regards,
A.D.Tejpal
--------------
  ----- Original Message ----- 
  From: DWUTKA at marlow.com 
  To: accessd at databaseadvisors.com 
  Sent: Monday, February 23, 2004 21:27
  Subject: RE: [AccessD] Access Form Outside The Application Container -
Making It Active Programmatically


  Try the AlwaysOnTop demo off of my site.  

  Drew (http://www.wolfwares.com)

  -----Original Message-----
  From: accessd-bounces at databaseadvisors.com
  To: Access Developers discussion and problem solving
  Sent: 2/22/04 11:18 PM
  Subject: [AccessD] Access Form Outside The Application Container - Making
It
  Active Programmatically

      This relates to a minimized Access 2000 application, where one of
  its forms is made to pop up on the desktop via API calls.

      Though everything proceeds as desired, the pop up form itself does
  not get focus until clicked upon. Following API calls have been tried -
  but no success in setting focus on the form -

      ShowWindow
      BringWindowToTop
      SetForegroundWindow
      SetActiveWindow
  '    SetFocus                     ' Gives Compile Error

      Note - FlashWindow and SetWindowText if tried, do what is expected
  but the focus gets lost eventually
          
      I shall be thankful for any help in this regard.

  Regards,
  A.D.Tejpal
  --------------

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list