What's the best way to keep a single form always on top of my VB app? I don't want it to be on top of other apps (like with HWND_TOPMOST), just mine.
Printable View
What's the best way to keep a single form always on top of my VB app? I don't want it to be on top of other apps (like with HWND_TOPMOST), just mine.
Private Sub Timer1_Timer()
Form1.zorder
End Sub
Private Sub Form_Load()
Timer1.Interval=250
End Sub
Hope this solves your problem.
Good luck
:p Kinjal :p
you could do
but that wont let you have acess to any other form, will form2 is closedCode:Form2.Show Vbmodal
Dennis- Thx, but I've got to use the other forms. This is sort of an "advertisement"
kinjalgp- Isn't there a more graceful way to do this? If I do it this way, the user will be able to "flash" the form under another and then back up.
Anyone?
This will definitely keep your form on top of all.
Public Sub AlwaysOnTop(Form1 As Form, SetOnTop As Boolean)
If SetOnTop Then
lFlag = HWND_TOPMOST
Else
lFlag = HWND_NOTOPMOST
End If
SetWindowPos Form3.hwnd, lFlag, Form1.Left / Screen.TwipsPerPixelX, _
Form1.Top / Screen.TwipsPerPixelY, Form1.Width / Screen.TwipsPerPixelX, _
Form1.Height / Screen.TwipsPerPixelY, SWP_NOACTIVATE Or SWP_SHOWWINDOW
End Sub
Private Sub Form_load()
AlwaysOnTop Form1, True
End Sub
Good Luck
:p Kinjal :p
try - form.show ,me
OK, let me clarify my question:
I have an app with about a dozen forms which open and close at various points in the application. I want one form to be on top of all of this (so I can't give it a distinct owner, _bman_) However, if my app is sent to the background I want this window to go with.
If you send your app to background then you can also set Form1's property somewhat like this
Private Sub Form1_LostFocus()
AlwaysOnTop Form1, False
End Sub
This will send Form1 behind other forms.;)