1

Нашел в интернете решение задачи, перемещения формы за панель. Прикрутил к себе, но работать не хочет.

private void panel1_MouseDown(object sender, MouseEventArgs e)
{
    base.Capture = false;
    Message m = Message.Create(base.Handle, 161, new IntPtr(2), IntPtr.Zero);
    this.WndProc(ref m);
}
2
  • что-то на C# смахивает. Это не javascript, поэтому и не работает
    – mountpoint
    15 дек 2013 в 16:04
  • Да, да вопрос по C#, Метку JS по ошибке написал.
    – Vlmake
    15 дек 2013 в 16:08

2 ответа 2

2

Вот так

  private void panel1_MouseDown(object sender, MouseEventArgs e)
    {
        panel1.Capture = false;
        Message m = Message.Create(Handle, 0xa1, new IntPtr(2), IntPtr.Zero);
        WndProc(ref m);
    }
1

Попробуй так:

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 panel1_MouseDown(object sender, MouseEventArgs e)
{     
    if (e.Button == MouseButtons.Left)
    {
        ReleaseCapture();
        SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
    }
}
2
  • увы не работает
    – Vlmake
    19 дек 2013 в 21:36
  • Только что проверил, все работает, и при передвижении за форму, и за панель. Вот проект: rghost.ru/51080759 19 дек 2013 в 21:53

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.