How can you test if a form is loaded?
Thanks!
Erica
Printable View
How can you test if a form is loaded?
Thanks!
Erica
Public Function IsLoaded(ByVal form_name As String) As Boolean
Dim frm As Form
IsLoaded = False
For Each frm In Forms
If frm.Name = form_name Then
IsLoaded = True
Exit For
End If
Next frm
End Function
Iouri Boutchkine
[email protected]
How do I bring a form window to the front? Is there a property that I can say frm.bringToFront? or something to that effect?
Thanks!
Erica
Use the ZORDER method ie:
Form1.Zorder 0
'or
Form1.Zorder 1
0 or Omitted says position form to the front. 1 says position it at the back.
John G
I'm trying that and its not working. I have a whole bunch of forms in an MDI application. I have a menu and when I click on a form off the menu that's already loaded, it won't bring it to the front...
Erica
Use the ShowWindow API.
Call ShowWindow(YourForm.hWnd,SW_SHOW)
If you need more control, then there is the SetWindowPos() API function
'
' Declarations
'
Public 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
'----------------------------------------------
' Sets a form Topmost
'
Public Sub SetTopMost(ByVal lHwnd As Long, ByVal bTopMost As Boolean)
'
' Set the hwnd of the window topmost or not topmost
'
Dim lUseVal As Long
Dim lRet As Long
lUseVal = IIf(bTopMost, HWND_TOPMOST, HWND_NOTOPMOST)
lRet = SetWindowPos(lHwnd, lUseVal, 0, 0, 0, 0, SWPFLAGS)
If lRet < 0 Then
'
' Couldn't do operation - handle error here
'
' DisplayWinAPIError lRet
End If
End Sub
==================
' To Set Form1 Top-Most
SetTopMost Form1.hwnd, True
' To set it back
SetTopMost Form1.hwnd, False
'===========================================use API from the top
'===One more way to set on top - On the form or module level
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Sub OnTopCheck_Click()
'------------------------------
If OnTopCheck.Value = vbChecked Then
SetWindowPos hwnd, HWND_TOPMOST,0,0,0,0, SWP_NOMOVE + SWP_NOSIZE
Else
SetWindowPos hwnd, HWND_NOTOPMOST,0,0,0,0, SWP_NOMOVE + SWP_NOSIZE
End If
End Sub
Iouri Boutchkine
[email protected]