Ok, I'm not wanting to use a module or anything to do this. I have a form that the user selects options on. I want to keep this window on top until it is closed. What's the EASIEST way to acomplish this?
Printable View
Ok, I'm not wanting to use a module or anything to do this. I have a form that the user selects options on. I want to keep this window on top until it is closed. What's the EASIEST way to acomplish this?
Depends on what you want. You can use API's to put the window on top while still being able to use other forms - like a Find window, for example.
For your purposes, just use show with vbmodal
Form1.Show vbModal
I'm executing code on the main form while the other windows are visible, and using vbmodal will kill that code. I just want to keep the window on top of Everything until it is closed, but still be able to use other forms.
VB Code:
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewLong As Long) As Long Private Const GWW_HWNDPARENT = -8 Public Function AlwaysOnTop(frm As Form, frmParent As Form) As Long On Error Resume Next AlwaysOnTop = SetWindowLong(frm.hwnd, GWW_HWNDPARENT, frmParent.hwnd) End Function
Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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
Private Sub TopMost(ByVal frm As Form)
SetWindowPos frm.hwnd, -1, &H3
End Sub
what syntax would I use on the form load event to make the form always on top?
TopMost (frmOptions)
I'm sure I screwed this up really bad so please help!;)