Click here to Skip to main content
15,898,371 members
Home / Discussions / C#
   

C#

 
Questionexit, minimize, maximize buttons on the form title bar Pin
quiteSmart8-Nov-06 21:45
quiteSmart8-Nov-06 21:45 
AnswerRe: exit, minimize, maximize buttons on the form title bar Pin
jiugarte9-Nov-06 0:49
jiugarte9-Nov-06 0:49 
GeneralRe: exit, minimize, maximize buttons on the form title bar Pin
quiteSmart9-Nov-06 1:16
quiteSmart9-Nov-06 1:16 
GeneralRe: exit, minimize, maximize buttons on the form title bar Pin
jiugarte13-Nov-06 1:23
jiugarte13-Nov-06 1:23 
try it.

private const int SC_CLOSE = 0xF060;
private const int SC_MAXIMIZE = 0xF030;
private const int SC_MINIMIZE = 0xF020;
private const int SC_RESTORE = 0xF120;

private const int MF_GRAYED = 0x1;

[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);

[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);

private void Disable_opt()
{
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_MAXIMIZE, MF_GRAYED);
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_MINIMIZE, MF_GRAYED);
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_RESTORE, MF_GRAYED);
}

Smile | :)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.