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); } :)
jiugarte
Posts
-
exit, minimize, maximize buttons on the form title bar -
How can I go to the last visited tab when the current tab is removed?to use a variable doesn't just solve the problem. for instance if you turn off 2 or more tabs consecutively it won't work. if you use a routine that allows to include and to remove several tabs then it should use a LIFO. when eliminating a tab it removes all the occurrences of this in the LIFO and go back to the last tab of the LIFO. :)
-
exit, minimize, maximize buttons on the form title barto remove. go to publishing Designer selects the form and change the property ControlBox to false. to intercept. public const int WM_SYSCOMMAND = 0x0112; public const int SC_CLOSE = 0xF060; protected override void WndProc(ref Message m) { if( m.Msg == WM_SYSCOMMAND) { if( (int) m.WParam.ToInt32() == SC_CLOSE ) { if (ProjectIsOpen) { return; } else { this.Close(); Application.Exit(); } } } base.WndProc (ref m); } :)