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

How do i set a window to be at the front of all other windows using VB

Status
Not open for further replies.

Largefry

Programmer
Apr 28, 2003
9
GB
Hi

How do i set a form to be at the front of all other windows using VB as i wish this screen to remain active until the allotted time has expired. Please help...??
 
The SetWindowPos API should work for you.

Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_FRAMECHANGED = &H20

Private 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)

The in code, the call would be as follows, from within the Form you want to bring topmost.

SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, (SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE)


Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top