INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

Windows API

How To Keep Your Form/Window On Top by percent
Posted: 12 May 04 (Edited 25 May 04)

If you would like to keep your window on top follow these steps - Add this code to your project you will need to add a timer named timer1 and add a checkbox named Check1 set the caption to "Stay On Top" set the timers interval to 1000 - (the lower the interval the quicker the window gets to the top) although 1000 should be fine since it is ever second
'-------------------CODE BELOW-----------------------------


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


Private Sub Check1_Click()
If Check1.Value = True Then
Timer1.Enabled = True
ElseIf Check1.Value = False Then
res& = SetWindowPos(me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
Timer1.Enabled = False
End If
End Sub

Private Sub Timer1_Timer()
res& = SetWindowPos(me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
End Sub



%, 2004

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close