-
I have a main form
It has several menus that open other forms.
Now if I open form1 and then click back on the main form to open form2, Form1 hides behind the main form.
How do I keep form1 in front of main form and allow form2 to be on top of both.
Basically like the desktop. Main form is the new desktop
-
Try this:
Code:
'Main Form
Form1.Show vbModal
'Form1
Private Sub Command1_Click()
Form2.Show vbModal
End Sub
-
that only allows you to open one form.
I need to be able to open several forms
is there an API call?
-
I see the problem, you want to have the main form as the foreground form, by that you said you clicked on it, but still have the other forms above, you may have to set them on top?
-
Kedaman,
how is that accomplished?
-
For code in a module:
Code:
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
And to set any window, on top you pass it's handle, that is the hwnd property on a form:
Code:
SetWindowPos Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS