|
-
March 27th, 2001, 04:44 PM
#1
Form Loaded
How can you test if a form is loaded?
Thanks!
Erica
-
March 27th, 2001, 04:46 PM
#2
Re: Form Loaded
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]
-
March 27th, 2001, 04:56 PM
#3
Re: Form Loaded
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
-
March 27th, 2001, 05:15 PM
#4
Re: Form Loaded
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
-
March 27th, 2001, 05:23 PM
#5
Re: Form Loaded
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
-
March 27th, 2001, 09:39 PM
#6
Re: Form Loaded
Use the ShowWindow API.
Call ShowWindow(YourForm.hWnd,SW_SHOW)
If you need more control, then there is the SetWindowPos() API function
-
March 28th, 2001, 08:52 AM
#7
Re: Form Loaded
'
' 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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|