Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Keeping a Window On Top
[ All Languages » VB »  Api]

Total Hit ( 3095)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
'Place this into your Module:

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 SWP_NOMOVE = 2
Global Const SWP_NOSIZE = 1
Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2

Sub OnTopYes(WinHandle As Long)
'This sub causes the window to stay OnTop
'WinHandle = the window handle
lResult = SetWindowPos(WinHandle, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
End Sub

Sub OnTopNo(WinHandle As Long)
'This sub prevents the window from staying OnTop
'WinHandle = the window handle
lResult = SetWindowPos(WinHandle, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
End Sub

'Now, when you want to make a window stay on top, just use the following code snippet:

Call OnTopYes(me.hwnd)

'This will force the calling window to stay above all other windows on your desktop!
'When you are finished with the window and don't want it above the other windows, just use 'this:

Call OnTopNo(me.hwnd)

'This will revert the window back to normal and it will act like a normal window.


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.