Drag windows window

Source: Internet
Author: User

Drag the Windows window and use wm_lbuttondown, wm_mousemove, and wm_lbuttonup to drag the window, which is very troublesome and prone to problems.

 

In Windows, these messages are provided. You only need to find these messages and then send them.

 

Generally, the button control converts wm_lbuttondown, wm_mousemove, and wm_lbuttonup messages to corresponding NC messages, that is, non-client messages, which are:

Wm_nclbuttondown, wm_ncmousemove, wm_nclbuttonup, there are many NC parts, and the drag is in the title part, so the second parameter is htcaption. When the system processes the NC message, it first sends the wm_nchittest message to find the NC part currently. DetailsCodeAs follows (cdragbutton is derived from cbutton ):

 

1
2 Void Cdragbutton: onlbuttondown (uint nflags, cpoint point)
3 {
4 // Todo: add your message handler code here and/or call default
5
6 Sendmessage (wm_nclbuttondown, htcaption, makelparam (point. X, point. y ));
7
8 // Cbutton: onlbuttondown (nflags, point );
9 }
10
11 Void Cdragbutton: onmousemove (uint nflags, cpoint point)
12 {
13 // Todo: add your message handler code here and/or call default
14 Sendmessage (wm_ncmousemove, htcaption, makelparam (point. X, point. y ));
15
16 // Cbutton: onmousemove (nflags, point );
17 }
18
19 Void Cdragbutton: onlbuttonup (uint nflags, cpoint point)
20 {
21 // Todo: add your message handler code here and/or call default
22 Sendmessage (wm_nclbuttonup, htcaption, makelparam (point. X, point. y ));
23 Cbutton: onlbuttonup (nflags, point );
24 }
25

 

 

However, when the cstatic control sends the above message, the system does not drag the window, And cstatic does not respond. It is said that the system has implemented some special shielding operations on the static control, however, you can drag through special messages, which is more concise than the above:

 

1 Void Cdragstatic: onlbuttondown (uint nflags, cpoint point)
2 {
3 // Todo: add your message handler code here and/or call default
4 Sendmessage (wm_syscommand, 0xf012 , 0 );
5 // Sendmessage (wm_nclbuttondown, htcaption, makelparam (point. X, point. y ));
6 // Cstatic: onlbuttondown (nflags, point );
7 }

 

 

Directly send the wm_syscommand and 0xf012 messages to the system to run the command accurately.

 

To process related messages in the control, You must select the notify attribute of the control.

 

 

 

 

Related Article

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.