By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,581 Members | 977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,581 IT Pros & Developers. It's quick & easy.

Modeless dialog as owner of a modal dialog

P: n/a
Hello
Can a modeless form be used as the "owner" of a modal form?

Here's the situation, from my MainForm, I have created a modeless form
using "Show" - and showed a modal form using "ShowDialog".

For some reason, if I do any user action on my modal form, it falls
behind the MainForm.

Any clues?
Thanks
Harsh

Mar 24 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ha******@tamaleresearch.com wrote:
Can a modeless form be used as the "owner" of a modal form?
Yes.
Here's the situation, from my MainForm, I have created a
modeless form using "Show" - and showed a modal form using
"ShowDialog".
Did you use ShowDialog(this) from the parent form?
For some reason, if I do any user action on my modal form,
it falls behind the MainForm.


Can you post a short program that shows this behaviour?

Eq.
Mar 24 '06 #2

P: n/a
Paul
Thanks for the reply.

I think I figured out what the problem was - a buggy(by design maybe??)
component.

I am using this third party drop down component, that basically creates
a new form on the dropdownclick event. The component uses a strange
logic to decide its parent, and that's what was causing the problem.

However, now I am having another problem.

I think its best to describe it with code, as you suggested.

In MainForm.cs:
try
{
OutlookSynchTool tool = new
OutlookSynchTool(OutlookSynchMode.Normal);
tool.Owner = this;
tool.InitializeGrid(); // this method call does loads the grid in
the form with data
tool.TopMost = true;
tool.ShowDialog(this);
}

OutlookSynchTool is extended from System.Windows.Forms.Form.

In the OutlookSynchTool class, there is call to the second dialog:
LinkNewContactToEntityDialog linkdialog = new
LinkNewContactToEntityDialog(mContactsToLink);
linkdialog.TopMost = true;
mLinkEntityToContactDelegate = new
LinkEntityToContactDelegate(linkdialog.ShowDialog) ;
if (InvokeRequired)
{
linkdialog.Invoke(mLinkEntityToContactDelegate, new object[1]
{this});
}
else
{
linkdialog.ShowDialog(this);
}

OutlookSynchTool is modal to MainForm. LinkNewContactToEntityDialog is
modal to OutlookSynchTool. When the input focus is in
LinkNewContactToEntityDialog, I can still interact with the
OutlookSynchTool dialog. I reckon this should be impossible, because of
the modal-ness - but ofcourse I am wrong.

Is this too confusing? Am I missing something?

Regards
Harsh

Mar 27 '06 #3

P: n/a
Hey Paul
I have figured it out. The problem was that the second form was being
created on a worker thread inside the first form. This led to the weird
behaviour.

Moving it into a Invoke, solved the problem.

Mar 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.