|
-
May 16th, 2006, 10:00 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [1.0/1.1] disabling resize / restore button in a form
Hi. Is there any way to disable the resize / restore button in a sizeable form? I don't want to delete it, just disable it.
Last edited by drattansingh; May 16th, 2006 at 12:02 PM.
-
May 16th, 2006, 03:50 PM
#2
Re: [1.0/1.1] disabling resize / restore button in a form
Well, you can modify the code found here to use the following constants:
Code:
const int SC_MAXIMIZE = 0xF030;
const int SC_MINIMIZE = 0xF020;
Cheers,
Ryan Jones
-
May 17th, 2006, 08:14 AM
#3
Thread Starter
Hyperactive Member
Re: [1.0/1.1] disabling resize / restore button in a form
Ok the following code disabled the close button:
Code:
private const int SC_CLOSE = 0xF060;
private const int MF_GRAYED = 0x1;
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);
private void Form1_Load(object sender, System.EventArgs e)
{
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);
}
I tried appending to the following:
Code:
const int SC_MAXIMIZE = 0xF030;
const int SC_MINIMIZE = 0xF020;
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);
private void Form1_Load(object sender, System.EventArgs e)
{
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_MAXIMIZE, SC_MINIMIZE );
}
I know I'm doing something wrong since it is not working, is anyone seeing what I'm diong wrong?
Jennifer
-
May 17th, 2006, 08:50 AM
#4
Thread Starter
Hyperactive Member
Re: [1.0/1.1] disabling resize / restore button in a form
I found something that works.
this.MaximizeBox = false;
-
May 17th, 2006, 03:08 PM
#5
Re: [1.0/1.1] disabling resize / restore button in a form
Sorry, it should have been this I think)
Code:
private const int MF_GRAYED = 0x1;
private const int SC_MAXIMIZE = 0xF030;
private const int SC_MINIMIZE = 0xF020;
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);
private void Form1_Load(object sender, System.EventArgs e)
{
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_MAXIMIZE, MF_GRAYED);
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_MINIMIZE, MF_GRAYED);
}
Cheers,
Ryan Jones
-
May 17th, 2006, 11:35 PM
#6
Re: [1.0/1.1] disabling resize / restore button in a form
 Originally Posted by JenniferBabe
I found something that works.
this.MaximizeBox = false;
Ryan always makes things over complex
-
May 19th, 2006, 07:35 AM
#7
Thread Starter
Hyperactive Member
Re: [1.0/1.1] disabling resize / restore button in a form
 Originally Posted by penagate
Ryan always makes things over complex 
LOL. Complex is good I'm sure that I will have need to it sometime. Thanks again ryan. and also you too penegate
-
May 19th, 2006, 08:39 AM
#8
Re: [RESOLVED] [1.0/1.1] disabling resize / restore button in a form
Just note that setting MaximizeBox to False is all well and good but if you set MinimizeBox to False as well then both the buttons will be removed altogether, not just disabled.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|