如何在 Panel 内移动 mousedrag 形成 window c++/CLR?

How do I make mousedrag inside Panel move form window c++/CLR?

我想启用这个 System::Windows::Forms::Panel,这样如果用户单击并拖动鼠标,就会将 window 拖到周围。

我可以这样做吗?我必须实施多个事件吗?

我建议您尝试致电 Control.MouseDown Event and Control.MouseMove Event

这是我的代码,建议你参考:

    Point pt;

    private: System::Void panel1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) 
    {
    
        Point mouseDownLocation = Point(e->X, e->Y);
        pt = Cursor->Position;

    }
    private: System::Void panel1_MouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) 
    {

        if (e->Button == System::Windows::Forms::MouseButtons::Left)
        {
            int px = Cursor->Position.X - pt.X;
            int py = Cursor->Position.Y - pt.Y;
    
            panel1->Location = System::Drawing::Point(panel1->Location.X + px, panel1->Location.Y + py);

            pt = Cursor->Position;
        }