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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep Form On Top...Visible

Status
Not open for further replies.

bblekfeld

Programmer
Mar 9, 2004
49
US
I am thinking there isn't, but does anyone know of a way to keep a form visible in other applications. It would be useful for me if I could set a form to "always be on top" of other applications. That way I could browse the web and easily enter data there etc. Its a longshot I know, but just checking.
 
Not hard at all, if you don't mind and are comfortable using some APIs, among them possibly FindWindow, and for sure, SetWindowPos.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks both of you for your help so far!

Just one question...umm :)...what's an API. Everyone keeps tossing that around.

I am familiar with global variables and functions and modules. But Im not exactly sure what API means or where you put that code.
Thanks again!
 
The API is the Application Program Interface.

The Windows API is a rather large set of functions that are available to Windows Programmers to perform system level functions, among them the type of window handling that you'll need to perform this task.

ByteMyzer and I were posting at the same time and I suggest that you follow that link and after reading that page, if you're still interested, then return and ask some specific questions and we'll help you along.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I have dropped the code below into a single module and placed a call to the function referencing the form in the open event (along with some other "docmd"s that I have running on OPEN)

Option Compare Database

The user32 is in quotes...am I supposed to replace that with my own info?


Also, the link you sent suggests you to remove the "_" line dividers. Is that a requirement, or is that optional?

Sorry, like I said, I am no VBA guru.




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


 
No, "user32" is the name of the system DLL in which the function resides.

Removing the "_" is optional.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I tried the below and its giving me error 13 type mismatch

Private Sub Form_Open(Cancel As Integer)
Me!CueNameLstBx.SetFocus
TopMost (Forms!OpenIssuesDrpDwn)

I tried the following and get a runtime 424

Private Sub Form_Open(Cancel As Integer)
Me!CueNameLstBx.SetFocus
TopMost (OpenIssuesDrpDwn)


Any ideas?


 
The TopMost function is expecting a form as a parameter. If OpenIssuesDrpDown a form, or a ComboBox?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Its called OpenIssuesDrpDwn because it contains a drpdwn that prefilters the next form.
 
One possible problem is that you have the form enclosed in parenthesis, which means that it is being evaluated as an expression, and the expression results will be the default property of the form, not the form itself.

Either add the keyword Call, or remove the parens.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top