2011-04-08 4 views
0

Possible en double:
How to make the Close button disabled in a windows Form using C# codingComment faire un bouton Fermer sous une forme désactivée

Je veux désactiver le bouton Fermer sous une forme peut me aider dans ce domaine.

+2

OK, nous avons besoin d'un groupe plus d'informations ici. Travaillez-vous dans WinForms, WPF, Silverlight ou ASP.NET? –

+0

Voulez-vous dire le bouton en haut à droite avec le «x»? –

+1

vote pour fermer comme doublon de [This] (http://stackoverflow.com/questions/5580512/how-to-make-the-close-button-disabled-in-a-windows-form-using-c-coding) – V4Vendetta

Répondre

0

Ce qui suit devrait aider:

[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); 

private void DisableCloseButton() 
{ 
    int menu = GetSystemMenu(Handle.ToInt32(), 0); 
    int count = GetMenuItemCount(menu); 
    RemoveMenu(menu, count - 1, MF_DISABLED | MF_BYPOSITION); 
} 
Questions connexes