In the graphical user interface, windows with borders are common and users can move them by dragging them. However, some applications may require borderless windows for specific aesthetic effects or functionality. But how do you make these borderless windows moveable?
An effective technique for creating removable borderless forms is to use Windows API functions:
Define two constants: WM_NCLBUTTONDOWN
represents the message sent when the left mouse button is pressed on the window, and HT_CAPTION
means that the click occurs in the title bar.
Import the necessary functions: SendMessage
Send a message to the window, ReleaseCapture
ReleaseCapture
In the
MouseDown
If yes, release the mouse capture and send a message to the window using
WM_NCLBUTTONDOWN and set
wParam to
HT_CAPTIONThis code actually simulates the mouse click on the title bar, allowing the form to be moved as usual.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3