Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Keep access 2000 window always on top

Posted on 2005-04-18
13
Medium Priority
?
786 Views
Last Modified: 2007-12-19
For a particular Access db, I want to keep my MS Access 200 window always topmost on the desktop - even when it loses focus.  

My access window is already sized and positioned (a low 200x600 profile in the lower left corner).  But now I want it to always stay on top, regardless of all other windows.  Currently, when another window is selected my access window loses desktop focus and jumps behind.  

Thanks
0
Comment
Question by:BHR
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 26

Expert Comment

by:dannywareham
ID: 13808773
OK - you need to be sneaky with this one.

First, set your form to Modal - that ensures that the form is always on top of teh Access window.

Now, you use this:

'This bit in the declarations
Public Declare Function GetActiveWindow Lib "user32" () As Long

'This bit in the timer event
If GetActiveWindow=0 Then
'Not Active, do something
Else
'Active, do something else
End If


This code (above) checks if the Access window is the curerntly viewed window.
0
 
LVL 39

Expert Comment

by:stevbe
ID: 13809446
and pray that no other developer used SendKeys or things are gonna start to get wild :-)
0
 

Author Comment

by:BHR
ID: 13811192
Thanks, this is a slick way of telling me whether access is topmost or not
However, where I'm stuck is in trying to set/keep the window as topmost

I have been trying to combine two functions...
one that allows me to size/position the access window
(based on http://support.microsoft.com/?kbid=210085)

one that keeps the MS Access window on top of all other application windows
(based on http://support.microsoft.com/default.aspx?scid=kb;en-us;101325)

I can get each one to work separately, but haven't been able to successfully combine them into a single function.
Thanks again!
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 26

Expert Comment

by:dannywareham
ID: 13813386
Try this.
Input teh second links' code into your database as far as "Function Float_Calc()".

Then use this:

'This bit in the declarations
Public Declare Function GetActiveWindow Lib "user32" () As Long

'This bit in the timer event
If GetActiveWindow=0 Then
'Not Active, do something
Dim X&, hwnd%
         X = Shell("CALC.EXE", 1)
         hwnd% = FindWindow%("SciCalc", 0&)

         Call SetWindowPos(hwnd%, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or _
            SWP_NOSIZE)
End If
0
 
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 450 total points
ID: 13814210
Hi,

  BHR e-mailed me off-line asking for some help.  Being new to EE, s/he wasn't sure how to proceed as an answer hasn't really been given yet.

  Work on this a bit more (from both sides) and if it still hasn't come to a conclusion, I'll post a link on Expert Notify so others can look at it.

BTW, This may be a re-hash of what's already posted, but it was a different KB # so I thought I'd post:

ACC2000: How to Make Microsoft Access Windows Stay on Top of Other Windows
http://support.microsoft.com/?kbid=210500

  At a brief glance, it sounds like what BHR may be looking for.

Jim.
0
 
LVL 26

Accepted Solution

by:
dannywareham earned 600 total points
ID: 13835625
Hi again.

Here's how to do from start to finish:

Open a new module.
Paste in this code:


Option Compare Database
Option Explicit
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
                                       ByVal hWndInsertAfter As Long, _
                                       ByVal X As Long, _
                                       ByVal y As Long, _
                                       ByVal cx As Long, _
                                       ByVal cy As Long, _
                                       ByVal wFlags As Long) As Long
Global Const HWND_TOPMOST = -1
Global Const SWP_NOSIZE = &H1
Global Const SWP_NOMOVE = &H2
     
Function TopMost(F As Form)
         Call SetWindowPos(F.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
                           SWP_NOMOVE Or SWP_NOSIZE)
End Function





'*******************************************************

Now, in the form that you want to "float", add this to the "OnTimer" event (it's in form properties, onthe events tab)

=TopMost([Form])

Set the timer interval as
50

On the "Other" tab, you'll find "Pop up"
Change this to "Yes"

Save and run teh form.
You'll see it floats over all your applications


:-)
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 14012109
BHR - how you getting on there...?

:-)
0
 

Author Comment

by:BHR
ID: 14015117
sorry.  maybe i'm daft, but none of these seems to quite cut it.  

My preferrence so far, is still what I originally had... using function sizeaccess (as described in http://support.microsoft.com/?kbid=210085).  

I've tried the other stuff, but the "topmost" function has two unwanted effects:
1) the window opens full size (where as I want a 200x1000 window in lower left corner of screen)
2) it makes the user unable to open or change focus to any other windows until you close Access down (whereas I want to be able to move around other apps... but keep access on top).

This Access app is for capturing reviews/scores of other documentation (in Word, Excel, etc.).  So I don't want to have to keep pulling it to the front while i'm moving around the other apps.

Thanks again all!
0
 
LVL 34

Assisted Solution

by:flavo
flavo earned 450 total points
ID: 14016248
FROM duplicate Q -> http:Q_21393613.html

Here we go.. Just change it from From.hwnd and use the Access Hwnd instead.

    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
                                       ByVal hWndInsertAfter As Long, _
                                       ByVal X As Long, _
                                       ByVal y As Long, _
                                       ByVal cx As Long, _
                                       ByVal cy As Long, _
                                       ByVal wFlags As Long) As Long
                                       
    Global Const HWND_TOPMOST = -1
    Global Const SWP_NOSIZE = &H1
    Global Const SWP_NOMOVE = &H2


    Function TopMost()
    '// Set Access as the top most window
        Call SetWindowPos(Application.hWndAccessApp, HWND_TOPMOST, 0, 0, 0, 0, _
                           SWP_NOMOVE Or SWP_NOSIZE)
    End Function

************************************************************
Just a warning... It wont let you open any other windows (focus on them) until you close Access down.

Dave
0
 
LVL 34

Expert Comment

by:flavo
ID: 14016254
oh... Im a little off...
0
 

Author Comment

by:BHR
ID: 14091055
Got it... several of you were driving me in the right direction using the "topmost" function from MS.   Although I tweaked it a bit to allow me to set size and pos.  I'll split up points for the help.  Thanks.

Here's what I ended up with:

      Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
                                       ByVal hWndInsertAfter As Long, _
                                       ByVal X As Long, _
                                       ByVal y As Long, _
                                       ByVal cx As Long, _
                                       ByVal cy As Long, _
                                       ByVal wFlags As Long) As Long
                       

      Global Const HWND_TOPMOST = -1
      Global Const SWP_NOSIZE = &H1
      Global Const SWP_NOMOVE = &H2
      Global Const SWP_NOZORDER = &H4
     
            Function TopMost(F As Form, cx As Long, cy As Long, _
  cHeight As Long, cWidth As Long)

         Call SetWindowPos(F.hwnd, HWND_TOPMOST, cx, cy, cWidth, cHeight, _
                           SWP_SHOWWINDOW)
      End Function
0
 
LVL 58
ID: 14097510

  Excellent!

Jim.
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 14097632
Muchas gracias...

Glad to have helped...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question