Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Form Always on Top Module
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Oct 8th, 2003 03:55 AM    Post subject: Form Always on Top Module Reply with quote

Hi!

Ever wondered how to put your form always on top of other windows ? This piece of code just let's you do that.

Put the code in a module:
[vb:1:c02619109e]Option Explicit

Private 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

Public Sub AlwaysOnTop(F As Form, Enabled As Boolean)
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2

If Enabled Then
SetWindowPos F.hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
SetWindowPos F.hwnd, -2, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub[/vb:1:c02619109e]
Usage:
[vb:1:c02619109e]AlwaysOnTop Me, True[/vb:1:c02619109e]
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic