Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cant show non-modal form....

Status
Not open for further replies.

richrock316

Programmer
Jul 30, 2003
57
0
0
US
I have a mdiform that calls a child form, the child has commondialog on it that I use to open a file. When I switch apps and then come back it shows the parent window and redraws it. It works fine everytime before I create the EXE.

After the EXE I get this problem. If I have the opendialog box open and then switch to an unrelated application and then come back I get this error "Can't show non-modal form when modal form is displayed".

Any ideas
Thanks,
Richard
 
Richard:

The modal form being referred to is the OpenFileDialog box. If I ventured a guess, it is probably hiding behind one of the executables that you are switching to.

When you are using parent/child relationships in forms and one of them is modal, you cannot access either the parent or the child until the modal form has been fully executed.

The only problem is that I cannot duplicate your error. Can you give us some code with which to work?

Ron



Ron Repp
 
If I comment out "contact.show", which is the parent it works fine, but of course that is necessary. I tried putting an unload for the openfiledialog right before "contact.show", but it wouldnt unload it


Public Sub Hook()
'Establish a hook to capture messages to this window
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
AddressOf WindowProc)
End Sub
Public Sub Unhook()
Dim temp As Long

'Reset the message handler for this window
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub

Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
'Check for the ActivateApp message
If uMsg = WM_ACTIVATEAPP Then
'Check to see if Activating the application
If wParam <> 0 Then

Contact.Show
' which_screen
End If
End If
'Pass message on to the original window message handler
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, _
lParam)
End Function


Here is the loadform for "Contact"

Private Sub MDIForm_Load()
Dim i As Integer
Dim Msg As String
Dim ScaleFactorX As Single, ScaleFactorY As Single ' Scaling factors
Dim objcontrol As Control
On Error GoTo ErrHandler
'Store handle to this form's window
gHW = Me.hwnd
Screen.MousePointer = 99
' Size of Form in Pixels at design resolution
DesignX = 800
DesignY = 600
RePosForm = True ' Flag for positioning Form
DoResize = False ' Flag for Resize Event
' Set up the screen values
Xtwips = Screen.TwipsPerPixelX
Ytwips = Screen.TwipsPerPixelY
Ypixels = Screen.height / Ytwips ' Y Pixel Resolution
Xpixels = Screen.Width / Xtwips ' X Pixel Resolution
' Determine scaling factors
ScaleFactorX = (Xpixels / DesignX)
ScaleFactorY = (Ypixels / DesignY)
Resize_For_Resolution ScaleFactorX, ScaleFactorY, 0, 0, 12000, 9000, Me
MyForm.height = Me.height ' Remember the current size
MyForm.Width = Me.Width
screen_res = DesignX / (Screen.Width / Screen.TwipsPerPixelX)
resX = 4300 / screen_res
resY = 4150 / screen_res
resRad = 3900 / screen_res
Load Cntrls
SetParent Cntrls.hwnd, Picture1.hwnd
Cntrls.Show

'Call procedure to begin capturing messages for this window
Hook
Unload Open_file
'Initialize variables
files_open = 0
filled.file0 = False
filled.file1 = False
filled.file2 = False
filled.file3 = False
filled.file4 = False
dragging = False
sect = "rect"

GMT = False
stat_change = "polar"
start_dir = CurDir
xt = resX
yt = resY
Exit Sub
ErrHandler:
Msg = "ERROR " & Err.Description
MsgBox Msg
Exit Sub

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top