Look at the Form.Closing event.
You can set
e.Cancel = true;
but be careful with your logic, so that you don't make it so that you cannot
close your form at all.
// Sample on how this can be done. Note that this will also prevent use of
the X button for exit.
// Only the Close button will allow this form to close.
private bool keepOpen = true;
private void ToolForm_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
e.Cancel = keepOpen;
}
private void buttonClose_Click(object sender, System.EventArgs e)
{
keepOpen = false;
this.Close();
}
Chris R.
"007" <00*@spy.com> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I have a FixedToolWindow form that I create and display when the user
presses a button on the toolbar. I want to prevent Alt+F4 on the
FixedToolWindow form. How do I accomplish this? I want the only way to
close the FixedToolWindow form is by clicking on the toolbar button again.
It's a bit like pressing "Search" on IE's toolbar.
BTW why is the ToolBar that comes with VS.NET so ugly? It's like the old
style toolbar.
Thanks.