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!

Form Always on top 4

Status
Not open for further replies.

ShortyII

Programmer
Sep 8, 2003
57
NL
Hi,

The question is the following.
I want to make a program that is always on top.
So if i open for example outlook the program i developt is on top of that.

Dos somebody knows how i can do this ???

Thanx
 
The way to do this is with the SetWindowPos API call with the HWND_TOPMOST parameter .

If you look it up in MSDN, I am sure you work out how to use it
in a module, paste
Code:
Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1

Public Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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

in the form (form load event might be ok)
Code:
with me
  SetWindowPos .hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
end with

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Matt,

That is an outstanding piece of code. Thanks a heap... and take a star!

"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top