Move the Untitled (Border) Form

Source: Internet
Author: User
I have seen a tutorial on csdn before. It is very troublesome to move the Untitled form. We need to redraw the form continuously.
Using this formborderstyle to set the form to none, you can easily customize the form skin, of course, the skin needs to make your own picture.

Today, I accidentally discovered a simpleCode, Called the system API
The following code exists in program. CS:

[Dllimport ( " User32.dll " )]
Public   Static   Extern   Bool Releasecapture ();
[Dllimport ( " User32.dll " )]
Public   Static   Extern   Bool Sendmessage (intptr hwnd, Int Wmsg, Int Wparam, Int Lparam );

Public   Const   Int Wm_syscommand =   Zero X 0112 ;
Public   Const   Int SC _move =   0xf010 ;
Public   Const   Int Htcaption =   Zero X 0002 ;

Then, enter the following code on the form to implement the function:

Private   Void Frminputpsd_mousedown ( Object Sender, mouseeventargs E)
{
// If the mouse pointer is within the range of the title bar and the left mouse button is pressed, the method of moving the title bar is triggered.
If (E. Button = Mousebuttons. Left && E. Y <=   25 )
{
Program. releasecapture ();
Program. sendmessage (This. Handle, program. wm_syscommand, program. SC _move+Program. htcaption,0);
}
}

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.