G
Greg Patrick
This problem occurs on Windows 2000 but NOT on Windows XP:
If you programmatically remove a control from the Controls collection of a
panel on another form, then that form's default WndProc will return FALSE to
the WM_QUERYENDSESSION message!
Is there anything that can be done to fix this other than overriding the
WndProc (which I don't want to do for performance reasons)?
Please help!
To reproduce: (on Win 2000 obviously)
VS.Net 2003, Framework 1.1 w/ service packs:
In VS.Net, create a C# win forms application with two Forms (e.g. Form1 and
Form2):
On Form1, drop two buttons.
On Form2, drop a panel, drop a button inside the panel. In Form2 code, make
panel1 be public.
In Form1, add a Form2 private variable (e.g. call it "form2"), then write
the first button's click handler:
if (this.form2 == null) this.form2 = new Form2();
this.form2.Show();
The second button's click handler:
this.form2.panel1.Controls.RemoveAt(0);
Then run it... click the first button, click the second button. You should
see the button disappear from the panel of form2. Then try to exit Windows
(or, a bit nicer, write something to FindWindow of the Form2 window and send
it WM_QUERYENDSESSION).
Thanks!,
Greg Patrick
If you programmatically remove a control from the Controls collection of a
panel on another form, then that form's default WndProc will return FALSE to
the WM_QUERYENDSESSION message!
Is there anything that can be done to fix this other than overriding the
WndProc (which I don't want to do for performance reasons)?
Please help!
To reproduce: (on Win 2000 obviously)
VS.Net 2003, Framework 1.1 w/ service packs:
In VS.Net, create a C# win forms application with two Forms (e.g. Form1 and
Form2):
On Form1, drop two buttons.
On Form2, drop a panel, drop a button inside the panel. In Form2 code, make
panel1 be public.
In Form1, add a Form2 private variable (e.g. call it "form2"), then write
the first button's click handler:
if (this.form2 == null) this.form2 = new Form2();
this.form2.Show();
The second button's click handler:
this.form2.panel1.Controls.RemoveAt(0);
Then run it... click the first button, click the second button. You should
see the button disappear from the panel of form2. Then try to exit Windows
(or, a bit nicer, write something to FindWindow of the Form2 window and send
it WM_QUERYENDSESSION).
Thanks!,
Greg Patrick