Open a popup window as modal

G

glenhong

Im trying to display a popup window (similar to a context menu) and
return a result from the selection. I want to do this as a modal popup
ie. The code runs and displays the popup but pauses until the window
is closed and then returns the result very similar as to ShowDialog()
on the form class.

The popup window is a 3rd party control which I hope to wrap up in
another class. I have tried using threads but have been unsuccesful,
the main problem being I block the UI thread which is no good.

Any help aprreciated.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I do not clear uderstand what is your problem, does ShowDialog doesn't
solve your problem?

cheers,
 
G

glenhong

The control that I am using does not implement a ShowDialog method. It
is a PopupControlContainer (behaves like a panel and pops up like a
Right-Click context menu would).

However I would like to display this popup modally i.e. Display the
popup and wait for it to close and continue code execution

eg.

void DisplayPopup(Control controlToPop)
{
PopupControlContainer pcc = new
PopupControlContainer(controlToPop);

pcc.ShowPopup();
//I would like the code to wait here until the popup has been
closed. Possibly with a thread or something similar???
MessageBox.Show(pcc.SomeValue);

}

This is a simplified version of what I am trying to acheive.

Really, any help appreciated.

Thanks
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


What if you include this control inside a form ( which is the control that
implement ShowDialog ) , this form will have only one control; yours


cheers,
 

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