In my program, im using the WndProc override to stop my form being resized. Thing is, the cursor is still there when you move the pointer to the edge of the form. Is there anyway to hide this cursor?
Why not set the FormBorderStyle
property appropriately instead? Then you don't need to use WndProc
either.
Here's some sample code to demonstrate - click the button to toggle whether or not the form can be resized:
using System;
using System.Windows.Forms;
using System.Drawing;
class Test
{
[STAThread]
static void Main(string[] args)
{
Button button = new Button
{
Text = "Toggle border",
AutoSize = true,
Location = new Point(20, 20)
};
Form form = new Form
{
Size = new Size (200, 200),
Controls = { button },
FormBorderStyle = FormBorderStyle.Fixed3D
};
button.Click += ToggleBorder;
Application.Run(form);
}
static void ToggleBorder(object sender, EventArgs e)
{
Form form = ((Control)sender).FindForm();
form.FormBorderStyle = form.FormBorderStyle == FormBorderStyle.Fixed3D
? FormBorderStyle.Sizable : FormBorderStyle.Fixed3D;
}
}
I have found a way using WndProc thanks to the link Lasse sent me. Thanks for your reply Jon but it wasnt exactly what i wanted. For those who want to no how i did it, i used this :
protected override void WndProc(ref Message message)
{
const int WM_NCHITTEST = 0x0084;
switch (message.Msg)
{
case WM_NCHITTEST:
return;
break;
}
base.WndProc(ref message);
}
i havent tested it thoroughly so dont no if there are any sideeffects but it works fine for me at the moment :)
Just setting FormBorderStyle is enough for this. Why are you using WndProc for this?
@Ozzy / Lasse Worked for me!
Had the same problem:
Standard border styles don't give the look I want, custom CreateParams do. I specified the same values for Size, MinimumSize and MaximumSize to disable resizing. The resize cursors were still being set though, thanks to Ozzy & Lasse this is now handled by filtering WM_NCHITTEST...
Thanks