Always on top

FloBob

Registered User.
Local time
Today, 16:22
Joined
Jul 19, 2002
Messages
108
Hello,

Does anyone know how to set a form to be always on top of the desktop? I have a caculator of sorts that I wish to keep on top of a as/400 green screen. Is this possible?... also does anyone know how to size Access windows.(not the form) the entire window? Thanks in advance.
 
I don't know how to make a window always on top, but I do with with popups, modal forms, and I usually set the active form to DoCmd.Mazimize.

You can find more information on these topics by selecting WindowState or BorderStyle Property in the Access Help, "Answer Wizard" section!
 
FloBob:

I believe the only way to make it the topmost on your desktop is to use API calls. If you are just beginning in your programming I would not suggest using them tho as it can really hork your computer if you do something wrong.
 
Set the Pop-up property of the form to Yes

Hmpff.. Sorry, I had not read properly. Let me a moment an I will post code for that.
 
Last edited:
Thanks so much for your assistance.

To clarify, I am not just dealing with a form of a database. I would like to control the entire database. How to set the database window 'Always on top' of other applications, IE the green screen. I would also like to size that window so that I can automatically make it small enough to sit in the bottom right of the users desktop, just above the systray.

[nateobot]

I would be interested to see if anyone has actually done this before.. I am not a beginning access programmer and would greatly appreciate advanced help with this. Do you have an example?
 
Last edited:
FloBob,

Test this out. There are of course ways to get around it being on the top but for most part this should work for you.

Bleh it is so much harder to do some of this API work in Access than VB.

-nate

Code:
Option Compare Database
Option Explicit
Private 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

' Topmost window
Private Const HWND_TOP = 0
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

Public Sub OnTop(ByVal lhWnd As Long)
  SetWindowPos lhWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
Public Sub NotOnTop(ByVal lhWnd As Long)
  SetWindowPos lhWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
Private Sub Command0_Click()
OnTop (Application.hWndAccessApp)
End Sub

Private Sub Command1_Click()
NotOnTop Application.hWndAccessApp
End Sub
 
Do I have to have adminstrator access to the PC to update this? I
 
Sorry I do not understand. You need to be able to have design access to the mdb. In my example below I just put the code in a form with two command buttons. One makes it topmost the other takes off topmost.

You should be able to customize it to your form easily.

Just call OnTop sub from your code.
 
That doesnt seem to work.... what OS is this on? Im curious if I have to have special permissions to user32 to be able to run this because it does not put it on top , and does not give me an error message.. I want to thank you for your help ... let me know.
 
This is for Windows versions I think 95+? I think 95 was when MS introduced the 32 bit stuff. Sorry I have never used AS400 so I am not sure what that platform is. Is it run on 16 bit? if so i can try to hunt down the 16 bit code.

user32 is a Windows dll file installed with Windows.
 
I am running windows 2k however I do not have administration right to my own machine. Part of the security policy we are using. I'm curious if I need to have special permissions to that file to be able to manipulate it. Thanks again, sorry to be a pain. As/400 green screen runs like any other windows application. Its just a window the trick is I want it below my calculator, and it doesnt seem to want to do it. You'd think they would make this a built in command. The utuility seems to be endless. Let me know.
 
You "shouldn't" need admin access to that file. All API calls do is lookup functions in those dll files. I have never been on a system that locked down so i cannot say for sure tho. Hope you can get it to work tho :)
 
Thank you so much for your help on this... I'll try some other ideas.
 
FloBob,

Test this out. There are of course ways to get around it being on the top but for most part this should work for you.

Bleh it is so much harder to do some of this API work in Access than VB.

-nate

Code:
Option Compare Database
Option Explicit
Private 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
 
' Topmost window
Private Const HWND_TOP = 0
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
 
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
 
Public Sub OnTop(ByVal lhWnd As Long)
  SetWindowPos lhWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
Public Sub NotOnTop(ByVal lhWnd As Long)
  SetWindowPos lhWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
Private Sub Command0_Click()
OnTop (Application.hWndAccessApp)
End Sub
 
Private Sub Command1_Click()
NotOnTop Application.hWndAccessApp
End Sub


EXCELLENT!!!

I was looking for this and this CODE works perfectly for me!!!!

TKS a lot
 

Users who are viewing this thread

Back
Top Bottom