|
-
Jan 17th, 2006, 11:21 AM
#1
Thread Starter
Fanatic Member
Is this form modal?
Is there anyway to tell if a particular form is modal or modeless?
Is there a property of the form I can check? Or perhaps some other way?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Jan 17th, 2006, 11:31 AM
#2
Re: Is this form modal?
The window style for the form being shown vbModeless will have a window style of WS_EX_APPWINDOW. For a Modal form its style will not have that style applied.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2006, 11:36 AM
#3
Thread Starter
Fanatic Member
Re: Is this form modal?
Do you know how to interrogate a form's window style? Presumably by some API call?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Jan 17th, 2006, 11:37 AM
#4
-
Jan 17th, 2006, 11:38 AM
#5
-
Jan 17th, 2006, 11:40 AM
#6
Re: Is this form modal?
I used MS Spy++ to determine the difference in classes and styles on my test forms. The app style was the only difference. Yes, SetWindowLong and GetWindowLong would be the APIs needed to read and set the style.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2006, 11:42 AM
#7
Re: Is this form modal?
To expand a bit on Rob's answer... It's the extended window style that will have the WS_EX_APPWINDOW bit set if the window is not shown modally. You can use this code to check that.
VB Code:
Private Declare Function GetWindowLong _
Lib "user32.dll" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long _
) As Long
Public Function IsFormModal(ByVal hWnd As Long) As Boolean
Const GWL_EXSTYLE As Long = -20
Const WS_EX_APPWINDOW As Long = &H40000
IsFormModal = Not ((GetWindowLong(hWnd, GWL_EXSTYLE) And _
WS_EX_APPWINDOW) = WS_EX_APPWINDOW)
End Function
Simply pass the hWnd of the Form you want to check to the IsFormModal function.
-
Jan 17th, 2006, 11:44 AM
#8
-
Jan 17th, 2006, 11:47 AM
#9
Re: Is this form modal?
If you mean me manavo11 then its just a matter of doing a little testing. Guess I had the time and energy this morning to do it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2006, 11:50 AM
#10
-
Jan 17th, 2006, 11:51 AM
#11
Re: Is this form modal?
Unfortunatly this is not true.... The WS_EX_APPWINDOW means that the window is shown in the TaskBar. It doesn't mean the form is modeless. If you set the BorderStyle of a Form to, for example, Fixed Dialog it will not have this window style regardless if that form is loaded modally or not.
-
Jan 17th, 2006, 11:53 AM
#12
-
Jan 17th, 2006, 11:58 AM
#13
Re: Is this form modal?
Ah, so it is. Guess I didnt test it throughly enough. My bad. 
So then any insight on what is the identifier JA?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2006, 12:01 PM
#14
Hyperactive Member
Re: Is this form modal?
You can check to see if you main form is enabled or not. If there is a form displayed modal then the form that brought it up is disabled.
-
Jan 17th, 2006, 12:04 PM
#15
Re: Is this form modal?
 Originally Posted by tward_biteme1
You can check to see if you main form is enabled or not. If there is a form displayed modal then the form that brought it up is disabled.
The form really isn't disabled, you just can't do anything with it, or any other window, until the modal form has been unloaded.
-
Jan 17th, 2006, 12:14 PM
#16
Re: Is this form modal?
It's pretty easy to create a Private property in a form so you can tell if it's modal or not.
CreateForm1 with two command buttons and form2 (the form to be shown vbModal) with one command button
VB Code:
' Form1 code
Option Explicit
Private Sub Command1_Click()
Form2.ShowForm = vbModal
End Sub
Private Sub Command2_Click()
Form2.ShowForm = vbModeless
End Sub
' Form2 code
Option Explicit
Private mintMode As Integer
Private Sub Command1_Click()
If Form2.ShowForm = vbModal Then
MsgBox "vbModal"
Else
MsgBox "Modeless"
End If
End Sub
Public Property Get ShowForm() As Integer
ShowForm = mintMode
End Property
Public Property Let ShowForm(ByVal intMode As Integer)
If IsMissing(intMode) Then
mintMode = vbModeless
Else
mintMode = intMode
End If
Me.Show intMode
End Property
-
Jan 17th, 2006, 12:15 PM
#17
Re: Is this form modal?
We had a need to "know" if a modal form was popped up on the screen - because we were subclassing for the APPACTIVATE message...
And if we messed with FORM focus with a MODAL form on the screen, VB choked.
We ended up creating a global boolean to track whenever a MODAL form was put on the screen so we could test that boolean.
One odd place this was required was when we started printing with the PRINTER object and the user had a PDF-writer as the default printer. That PDF-writer would pop-up a file dialog box to ask for output filename. So we needed to set that global boolean at the start of a report as well.
-
Jan 17th, 2006, 12:30 PM
#18
Re: Is this form modal?
 Originally Posted by Hack
The form really isn't disabled, you just can't do anything with it, or any other window, until the modal form has been unloaded.
Well, actually the owner form is disabled. However the Enabled property in VB isn't set but you can check if the owner form has the WS_DISABLED style bit set.
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
|