0

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.

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by riahc3
0

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
}

Edited by skatamatic

0

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 :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.