C # Control Drag

Source: Internet
Author: User

Https://zhidao.baidu.com/question/2116834779399609987.html

[DllImport( "user32.dll" , EntryPoint =  "ReleaseCapture" )] public static extern void ReleaseCapture(); [DllImport( "user32.dll" , EntryPoint =  "SendMessage" )] public static extern void SendMessage( int hwnd,  int wMsg,  int wParam,  int lParam);

Load the above statement into the form class file and add an event to the dragged control, such as I am a panel

        privatevoidpanelForm_MouseDown(objectsender, MouseEventArgs e)        {            if(e.Button == MouseButtons.Left)            {                ReleaseCapture();                SendMessage((int)移动的对象.Handle, 0xA1, 2, 0);                //是窗体自身就是                //SendMessage((int)this.Handle, 0xA1, 2, 0);                //panel就是SendMessage((int)panel1.Handle, 0xA1, 2, 0);            }        }

This is the Windows standard drag-and-drop event, the following, drag the time the window is flashing constantly, has been rendering the background

C # Control Drag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.