Hello

Im doing this code for every form Ive doing (you have have seen it so I wont explain it)

protected override void WndProc(ref Message m)
        {
            const int WM_MOVE = 0x0003;

            switch (m.Msg)
            {
                case WM_MOVE:
                    return;

                default:
                    base.WndProc(ref m);
                    break;
            }
        } 

How can I do this so I dont have to copy and paste this line over and over and over in every form? I thought of a module but then maybe a user defined form (which I have no idea how to do) which gets from the default form plus this code.

If someone could give a few tips, thanks.

Make a form that is derived from a regular form and put that code in it. Then to make forms that use that code just derive them from it. If you want to use it between projects you will need to either make a dll and reference it, or include the whole project each time and reference it (dll's probably easier)

public class UnmovableForm : Form
{
   //...Regular form stuff goes here (might want to seperate the designer code though)
   public override WndProc()... //your method
}

public class NewForm : UnmovableForm
{
   //This form will use that same WndProc() override
}

Make a form that is derived from a regular form and put that code in it. Then to make forms that use that code just derive them from it. If you want to use it between projects you will need to either make a dll and reference it, or include the whole project each time and reference it (dll's probably easier) public class UnmovableForm : Form{ //...Regular form stuff goes here (might want to seperate the designer code though) public override WndProc()... //your method}public class NewForm : UnmovableForm{ //This form will use that same WndProc() override}

I THINK I understand what you mean.........Im going to have to try it out just in case.

Thanks a lot :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.