1. Can't show non-modal form when modal form is displayed
Hi everyone, I have a modal userform that contains a button (among other controls). When a user clicks this button, another, modeless userform (frmHelp) should be displayed that contains information about the first form. It would be nice if users were able to access the first form while this information is still shown - hence the choice for modeless display. Clicking the button results in run time error 401: Can't show non-modal form when modal form is displayed. Both setting the ShowModal property of frmHelp at design time to False and 'frmHelp.Show vbModeless' yield the error. Is there any way to bypass this error and have the second form displayed modeless just the same? Displaying the first form modeless works, but in this way users can get at the Word document, which is out of the question. I use Word 2003. Thank you, Cooz
2. Using non-modal forms when modal form displayed - Visual Basic/VB
3. Can't Show Non-Modal Form...........?
In a WebBrowser project, I have given users the option to set their
default browser to my browser i.e. whenever any HTML file is opened in
Windows Explorer, the HTML file should open with my browser. The
project also houses a CheckBox for the browser to check whether it is
the default browser or not. If not, then when the browser is run on the
first time, a MsgBox should come up asking the user if he would like to
set my browser as the default browser in his machine. If Yes, then my
browser will be set as the default browser in that machine else the
existing default browser will remain the default browser. This is how I
am checking whether my browser is the default browser or not (NOTE:
This is not my code):
visual basic code:
Private Sub Form_Load()
If (frmBrowserOptions.chkDefault.Value = vbChecked) Then
Call CheckDefault
End If
End Sub
Private Sub CheckDefault()
Dim success As Long
Dim sBrowser As String
'success is passed and filled in the routine
sBrowser = GetBrowserName(success)
'possible return values from the call returned in success
Select Case success
'the call succeeded
Case Is >= ERROR_FILE_SUCCESS
If (InStr(sBrowser, "MyBrowser.exe") = 0) Then
If (vbYes = MsgBox("MyBrowser not default browser! Set
it as default?", vbYesNo + vbQuestion)) Then
Call frmBrowserOptions.cmdDefault_Click
End If
End If
Exit Sub
'other possible return values
Case ERROR_FILE_NO_ASSOCIATION
Case ERROR_FILE_NOT_FOUND
Case ERROR_PATH_NOT_FOUND
Case ERROR_BAD_FORMAT
Case Else
End Select
End Sub
Private Function GetBrowserName(dwFlagReturned As Long) As String
Dim hFile As Long
Dim sResult As String
Dim sTempFolder As String
'get the user's temp folder
sTempFolder = GetTempDir()
'create a dummy html file in the temp dir
hFile = FreeFile
Open sTempFolder & "dummy.html" For Output As #hFile
Close #hFile
'get the file path & name associated with the file
sResult = Space$(MAX_PATH)
dwFlagReturned = FindExecutable("dummy.html", sTempFolder, sResult)
'clean up
Kill sTempFolder & "dummy.html"
'return result
GetBrowserName = TrimNull(sResult)
End Function
Private Function TrimNull(Item As String)
Dim pos As Integer
pos = InStr(Item, Chr$(0))
If pos Then
TrimNull = Left$(Item, pos - 1)
Else
TrimNull = Item
End If
End Function
Public Function GetTempDir() As String
Dim nSize As Long
Dim tmp As String
tmp = Space$(MAX_PATH)
nSize = Len(tmp)
Call GetTempPath(nSize, tmp)
GetTempDir = TrimNull(tmp)
End Function
'this is the cmdDefault_Click event function in another Form named
frmBrowserOptions
Sub cmdDefault_Click()
......................
......................
......................
End Sub
Assume that my browser is not the default browser. Now when I run the
browser from the IDE, the MsgBox asking the user whether he would like
to set my browser as the default browser or not comes up as expected
but when I compile the project into an EXE & then open my browser
(again assuming that my browser isn't the default browser), the MsgBox
comes up but immediately after that, VB generates the "Can't show
non-modal form when modal form is displayed" error.
Next irrespective of whether I click Yes or No in the MsgBox, the
following error gets generated:
An exception 'Unhandled Win32 Exception' has occured in MyBrowser.exe.
However, no debuggers are registered that can debug this exception.
Unable to JIT debug.
After this, the browser closes. My guess is that when the browser
loads, the other Form named frmBrowserOptions also Now how do I avoid
these 2 errors when I run the EXE? Please note that these 2 errors
don't get generated when I run the project from the VB IDE.
Thanks,
Arpan
4. Runtime error 401 - Can't show non modal form when modal form is displayed.
5. Non Modal Forms on Top of Modal One's
I wonder if there's any way around this. I open a window as a modal form, but I would like to have pop up message boxes appearing on top of this that are non modal (so the user can close whichever of the pop ups they like). If I make the parent window non modal this works fine. I simply set the TopMost property for each pop up so that is stays on top of the parent. However as soon as I make the parent window modal (which is absolutely essential in my project) although the pop up windows appear you can no longer interact with them. Is there any way of getting this to work. I hoped that setting parents and owners would have an affect but so far nothing... Thanks
6. Displaying a progress dialog - Modal / Non Modal error - Visual Basic/VB
7. Trying to Display a non-modal VB6 Form of an AcitveX DLL in C#
Hallo NG, I'm trying to display a VB6 6 of an ActiveX DLL in c Sharp. I use therefore the SetParent API function. After this function call I get always the error message "Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property Page.". Does somebody know if it is possible to show a non modal Form, or has sombebody a workaround for that. Thanks for your help. Regards Martin