Modal UserControl, exist some way?
-
Hi friends, This time I have a very strange need, I recognize ;-)! In my application, there is three custom UserControls that represent "windows": MyFakeWindow UserControl1 MyFakeWindow UserControl2 MyFakeWindow UserControl3 There is also, a "FakeWindowManager" that controls which window is the current, which the windows order and things like this. Two methods stand out: void FakeWindowManager.Load(MyFakeWindow window) DialogResult FakeWindowManagerAsModal.Load(MyFakeWindow window) The problem is in the second method. How to do to simulate a MODAL window? Does anybody have an idea? Any suggestion, road, shines, am accepting everything... :D Thank´s in advance, Marcelo Palladino Brazil
-
Hi friends, This time I have a very strange need, I recognize ;-)! In my application, there is three custom UserControls that represent "windows": MyFakeWindow UserControl1 MyFakeWindow UserControl2 MyFakeWindow UserControl3 There is also, a "FakeWindowManager" that controls which window is the current, which the windows order and things like this. Two methods stand out: void FakeWindowManager.Load(MyFakeWindow window) DialogResult FakeWindowManagerAsModal.Load(MyFakeWindow window) The problem is in the second method. How to do to simulate a MODAL window? Does anybody have an idea? Any suggestion, road, shines, am accepting everything... :D Thank´s in advance, Marcelo Palladino Brazil
-
Hi friends, This time I have a very strange need, I recognize ;-)! In my application, there is three custom UserControls that represent "windows": MyFakeWindow UserControl1 MyFakeWindow UserControl2 MyFakeWindow UserControl3 There is also, a "FakeWindowManager" that controls which window is the current, which the windows order and things like this. Two methods stand out: void FakeWindowManager.Load(MyFakeWindow window) DialogResult FakeWindowManagerAsModal.Load(MyFakeWindow window) The problem is in the second method. How to do to simulate a MODAL window? Does anybody have an idea? Any suggestion, road, shines, am accepting everything... :D Thank´s in advance, Marcelo Palladino Brazil
A control and a window are distinct window classes with different window styles. Instead of having to modify window styles and going to the work of implementing a pump, simply host the control in a borderless form and return the dialog result from the form:
public static DialogResult Load(MyFakeWindow window)
{
Form f = new Form();
f.FormBorderStyle = FormBorderStyle.None;
f.Controls.Add(window);
window.Dock = DockStyle.Fill;
DialogResult result = f.ShowDialog();
f.Dispose();
return result;
}-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----