Contact US

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.

Students Click Here

Visual Basic (Classic) 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

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 (Classic) FAQ Index
Back to Visual Basic (Classic) Forum

My Archive

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