This will not allow form to close form any other source also. Well i can
assign a bool when form is closed from other source but that is fixing and
not the sloution ...
In Vb it is possible to disable the close button .... isnt there anything
like that in C#
You said the same thing I was thinking of when you mentioned the bool.
You also might be able to test the value of the sender and compare it
to something to see where it came from and decide what to do. I cant
think of anything thats just a single click. You would think something
that simple would be in there. Keep us updated.
[DllImport("user32.dll")]
private static extern int GetSystemMenu(int hwnd, int revert);
[DllImport("user32.dll")]
private static extern int GetMenuItemCount(int menu);
[DllImport("user32.dll")]
private static extern int RemoveMenu(int menu, int position, int flags);
protected void DisableCloseButton()
{
int menu = GetSystemMenu(Handle.ToInt32(), 0);
int count = GetMenuItemCount(menu);
RemoveMenu(menu, count - 1, MF_DISABLED | MF_BYPOSITION);
}
Aleksandar
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.