6

In my program, I'm 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 any way to hide this cursor?

1

3 Answers 3

8

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;
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

i have it set to resizeable toolbox because in vista, you get that nice border around it. using fixed 3d, you dont get that border (i set controlBox to false and no title)
Assuming you mean SizeableToolWindow, have you tried FixedToolWindow? It looks exactly the same to me, just not resizeable.
Only when its set to resizeable does the border appear when controlbox is false and text is ""
7

I have found a way using WndProc thanks to the link Lasse sent me. Thanks for your reply Jon but it wasn't exactly what I wanted. For those who want to know how I did it, I used this:

    protected override void WndProc(ref Message m)
    {
        const int WM_NCHITTEST = 0x0084;

        switch (m.Msg)
        {
            case WM_NCHITTEST:
                return;
        }

        base.WndProc(ref m);
    }

I haven't tested it thoroughly so don't know if there are any side-effects but it works fine for me at the moment :).

1 Comment

I was about to answer something like that when you posted, glad you found your answer. You don't need a break after the return though.
0

Just setting FormBorderStyle is enough for this. Why are you using WndProc for this?

1 Comment

because in this case formborderstyle is not enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.