I am current developing a WinForm app that contain's a form that may be docked on the desktop, in a similar manner to the task bar. This uses the SHAppBarMessage API, and is based on the sample app posted on this site by Fred Balsiger.
I want to display a 'Are you sure ' message box on closing. To do this I have added an event handler to the Form_Closing event. When I close the form while it is docked, as it displays the message box, it loses the docking. The form stays where it is (i.e. at the top of the screen), but other items on the desk top move over the form (e.g. if there is a maximized window open, it expands over the toolbar app)
Can anybody explian why this could be happening, and how to stop it

Desktop Toolbar application use with message boxes
Kaveh Shahbazian
Anyway, I put attached the message box to the close button event as you suggested and it worked like a dream.
Thanks very much for posting your sample app - it has been very useful for me.
Regards
Robin
Gmumumbuh
With the sample I posted, try adding your MessageBox code to the "Close" button's click event instead of responding to the OnClosing notification. Something like this...
//Close_button_click_event {
DialogResult res = MessageBox.Show("Are you sure you want to close ", "Close ", MessageBoxButtons.OKCancel);
if (res == DialogResult.OK)
{
this.Close();
}
//end Close_button_click_event
...this should work much better for you.
Good luck,
-Fred