Hi.
I have a GDBG in which I''d like to ensure that the user has the option to save any unsaved changes when the application is being shut down.
In the C/C++ world, I would handle WM_CLOSE or WM_DESTROY for the window or control I''m coding.
What should I use in .NET?
Thanks,
Andy
HP
Holger Persch
October 27, 2004 03:19 AM UTC
Hi Andy,
You can handle the form''s "Closing" event. The CancelEventArgs is providing a "Cancel" member that can be used to prevent closing the form.
Regards,
Holger Persch
AD
Administrator
Syncfusion Team
October 27, 2004 09:02 AM UTC
I''m actually looking for a way to hook into the closing of a UserControl-derived control as opposed to a form.
At the Windows SDK level, I know that WM_DESTROY (or WM_CLOSE) will always be called for every window. So if I create a custom control, that control will receive a WM_DESTROY message when that control is being destroyed no matter what the reason (be it application shutdown, or some other user-generated reason).
I saw that UserControl has a HandleDestroyed event which looked promising. But it does not appear to be fired at the time that the user closes the tab-page in which my control resides (it gets called later when shutting down the app).
>Hi Andy,
>
>You can handle the form''s "Closing" event. The CancelEventArgs is providing a "Cancel" member that can be used to prevent closing the form.
>
>Regards,
>Holger Persch
HP
Holger Persch
October 28, 2004 03:02 AM UTC
Hi Andy,
What''s about this?
protected override void WndProc(ref Message message)
{
if (message.Msg == 0x0002 /* WM_DESTROY */)
{
}
base.WndProc(ref message);
}
Regards,
Holger
AD
Administrator
Syncfusion Team
October 28, 2004 01:52 PM UTC
Thanks for your help.
What I''ve done, temporarily, is to add some code that calls the control''s parent''s dispose method when that control is being closed. This forces an immediate call to HandleDestroyed in which I can manage saving any unsaved changes.
>Hi Andy,
>
>What''s about this?
>
>protected override void WndProc(ref Message message)
>{
> if (message.Msg == 0x0002 /* WM_DESTROY */)
> {
> }
>
> base.WndProc(ref message);
>}
>
>Regards,
>Holger
SS
Sharad Sharma
July 12, 2005 08:30 AM UTC
Hi Andy,
I found this page while searching a solution for "incorporating a user control (with a combobox and a button) into a GridDataBoundGrid (not the normal GridControl)".
Can you help me out in this probles as much as you can.
Thanks and regards.
KAPIL S.
>I''m actually looking for a way to hook into the closing of a UserControl-derived control as opposed to a form.
>
>At the Windows SDK level, I know that WM_DESTROY (or WM_CLOSE) will always be called for every window. So if I create a custom control, that control will receive a WM_DESTROY message when that control is being destroyed no matter what the reason (be it application shutdown, or some other user-generated reason).
>
>I saw that UserControl has a HandleDestroyed event which looked promising. But it does not appear to be fired at the time that the user closes the tab-page in which my control resides (it gets called later when shutting down the app).
>
>
>>Hi Andy,
>>
>>You can handle the form''s "Closing" event. The CancelEventArgs is providing a "Cancel" member that can be used to prevent closing the form.
>>
>>Regards,
>>Holger Persch