Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Always on Top 1

Status
Not open for further replies.

Prophets

Programmer
Nov 5, 2003
14
CA
Is there a way to make Access "Always on top?"
I have a small form that I want to be displayed on top of all windows all the time. Even outside of access. If there is a way I am sure that it would have to be for Access its self to be always on top. Any Ideas?
 
Have you tried using the SetWindowPos API call using the form's window handle as the handle to set Topmost?

In the declarations section of a module, add the following constants and declarations.

Public Const HWND_TOPMOST = -1
Public Const SWP_SHOWWINDOW = &H40
Public Const SWP_NOSIZE = &H2

Public Declare Sub 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)
[/code]
Then from within the form, at the point where you want to make this window topmost, make the following API call. I don't want the Window to be resized in this case either, so I disallow that as well. There are other options that you can read about.
Code:
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOSIZE

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hey CajunCenturion, Thanks. Its NOT working :(
This is what I did: In Declaration Section of a Module

Option Compare Database

Public Const HWND_TOPMOST = -1
Public Const SWP_SHOWWINDOW = &H40
Public Const SWP_NOSIZE = &H2

Public Declare Sub 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)

Then I created a form to test it. With a button and in the on click event I put the following:

Private Sub Cmd_AOT_Click()

SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOSIZE

End Sub

 
If some could let me know if the above works, that would be appreciated.
 
Sorry, I was in a hurry when I posted that this morning, and my real job kept me from getting back any sooner.

This does work in VB6 but apparently not in Access. Need to delve into it further, as Access must be doing something to it's child windows.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
But this in combination with setting the Popup property of the form to True does work.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
When I set the pop up to yes, and then run the form, it goes invisible.
 
Thanks man! I Got it to work, obviously using 0,0,0,0 it would be invisible. Thanks a bunch
 
Glad you got it work.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
One more Q, When I click on an element on the form that is Always on top it bring Access back up, is there a way to lock it down?
 
Sorry, Even 1 more Question, I would like this form not only to not maximize access when you click on a control, but could I make it so that other applications will not go underneth it? Basically the part of the screen is locked and the other apps will only maximize to the rest of the screen.

Am I asking too much? :) I really appreciate your help.
I put in 1,1,900,40 to have a small sliver of the top of the screen but its not puting it in the top left hand corner.
 
Needed this today....thanks cajun. You deserve a [star].

****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top