Hi All
I am working on windows application in C#, In that a form is there , that form boder style is set to none. And I am using a class CustomizePictureBox this class is inherited from PictureBox Class.
By drag and Drop i add this CustomizePictureBox to the form.
In the derived class CustomizePictureBox i have added the code
public
const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute ("user32.dll")]
public static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
[DllImportAttribute ("user32.dll")]
public static extern bool ReleaseCapture();
private void CustomizePictureBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
and while running the application this if i click left mouse button and move the pointer only the CustomizePictureBox is moving inside the form not the form
But if i add this event in the Form1.cs on the mouse down event of CustomizePictureBox then this works fine.. Means the form will move as mouse ponter moves with left mouse buttton pressed.
Can anybody help me out in this . I want that form moves with this PictureBox(PictureBox acts like as a CaptionBar) and events are added in dericed Class , because it is difficult to add the same event in all the forms ..