Urgent help needed with MDI Forms

F

feltra

Hi,

The following is from my friend, who has some technical problem at
present in accessing the web... I am writing for him... Kindly
request your inputs ASAP, as he has some kind of deadline tomorrow.

..........................................................................................
I am having an issue with MDI form. I have an MDI form and some Child
forms. In order to enable for a choice, I am displaying a message box
in the FormClosing event of both the forms. When the form is closed
individually, the code works fine, closing the form depending on
confirmation from the user, other wise the e.Cancel event is set to
true.
The problem is when I try to close the MDI form when the child
forms are open. By virtue of the property in .NET it goes through the
closing events of all the forms.., finally running the closing event
of the MDI form, which is undesirable. Is it possible to display a
different message box and close all child forms and the MDI form also,
without calling the formclosing method of the child forms?

If not, how do i display a message box confirmation when user clicks
on the X on the form? Please help me.. Its urgent...
............................................................................................

Thanks & Regards,
-feltra
 
R

rowe_newsgroups

Hi,

The following is from my friend, who has some technical problem at
present in accessing the web... I am writing for him... Kindly
request your inputs ASAP, as he has some kind of deadline tomorrow.

.........................................................................................
I am having an issue with MDI form. I have an MDI form and some Child
forms. In order to enable for a choice, I am displaying a message box
in the FormClosing event of both the forms. When the form is closed
individually, the code works fine, closing the form depending on
confirmation from the user, other wise the e.Cancel event is set to
true.
The problem is when I try to close the MDI form when the child
forms are open. By virtue of the property in .NET it goes through the
closing events of all the forms.., finally running the closing event
of the MDI form, which is undesirable. Is it possible to display a
different message box and close all child forms and the MDI form also,
without calling the formclosing method of the child forms?

If not, how do i display a message box confirmation when user clicks
on the X on the form? Please help me.. Its urgent...
...........................................................................................

Thanks & Regards,
-feltra
Is it possible to display a
different message box and close all child forms and the MDI form also,
without calling the formclosing method of the child forms?

Well, the formclosing method is going to be called on all of them
period. What your friend could do is have a public property that
controls which message is shown (if any) on closing. Then you just
have to set that property before the method is called.
If not, how do i display a message box confirmation when user clicks
on the X on the form?

I'm not in Visual Basic right now, so I can't confirm this, but if you
want to do something immediately after the "X" is clicked and before
any formclosed events fire, you'll probably need to override wndproc
and listen for the appropriate window's message. Then just loop
through any mdi children the form has and set the above mentioned
property that will prevent the messages from showing. Below is an old
post from Herfried Wagner that demonstrates what to do in the wndproc
method. You should be able to adapt it to what you need.

Thanks,

Seth Rowe

Is there a way I can get into a form's close/minimize/maximize events when
those buttons (the 3 small squared button in the upper right corner of a
form) are clicked?

\\\
Private Const WM_SYSCOMMAND As Int32 = &H112

Private Const SC_MAXIMIZE As Int32 = &HF030
Private Const SC_MINIMIZE As Int32 = &HF020
Private Const SC_RESTORE As Int32 = &HF120
Private Const SC_CLOSE As Int32 = &HF060

Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND Then
Select Case m.WParam.ToInt32()
Case SC_MAXIMIZE
Debug.WriteLine("Form gets maximized.")
Case SC_MINIMIZE
Debug.WriteLine("Form gets minimized.")
Case SC_RESTORE
Debug.WriteLine("Form gets restored.")
Case SC_CLOSE
Debug.WriteLine("Form gets closed.")
End Select
End If
MyBase.WndProc(m)
End Sub
///
 
F

feltra

Thanks a lot for the quick response, Rowe. I have fwded your message
to my friend... Hope it solves the problem for him...

Thanks & Regards,
-feltra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top