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.