Non-title bar drag MFC dialog box

Source: Internet
Author: User

Onnchittest
Cwnd: onnchittest
Afx_msg uint onnchittest (cpoint point );
Return Value: one of the enumerated values of the mouse hitting Test listed below.
· Htborder is placed on the border of a window without a mutable border.
· Htbottom is at the bottom of the horizontal border of the window.
· Htbottomleft is in the lower left corner of the window border.
· Htbottomright is in the bottom right corner of the window border.
· Htcaption is in the title bar.
· Htclient is in the customer zone.
· The partition ror is located on the screen background or the separation line between windows and windows (similar to htnowhere, except that the defwndproc function of Windows generates a system noise to indicate an error ).
· Htgrowbox in the dimension box.
· Hthscroll is on the horizontal scroll bar.
· Htleft is on the left border of the window.
· Htmaxbutton is on the maximize button.
· Htmenu is in the menu area.
· Htminbutton.
· Htnowhere is located on the separator line between the screen background or window.
· Htreduce is on the minimization button.
· Htright is on the right border of the window.
· Htsize is in the size box. (Same as htgrowbox)
· Htsysmenu is on the close button of the control menu or subwindow.
· Httop is above the horizontal border of the window.
· Httopleft is in the upper left corner of the window border.
· Httopright is in the upper right corner of the window border.
· Httransparent is in a window that is overwritten by other windows.
· Htvscroll is in the vertical scroll bar.
· Htzoom is on the maximize button.
Parameter: Point contains the x-axis and Y-axis coordinates of the cursor. These coordinates are always given by screen coordinates.
Note: whenever the mouse moves, the Framework calls this member function for the cwnd object that contains the cursor (or uses the setcapture member function to capture the cwnd object entered by the mouse.
Note that the Framework calls this member function to allow your application to process a Windows message. The parameters passed to your member functions reflect the parameters received by the framework when a message is received. If you call the basic class implementation of this function, the implementation will use the parameter originally passed to the message (instead of the parameter you provided to this function ).
Example:
How can we drag a program if the interface drawn by the application does not have a title bar? Then you can add the following message:
Uint cmainwindow: onnchittest (cpoint point)
{
Uint nhittest = cframewnd: onnchittest (point );
If (nhittest = htclient) // if it is a customer Zone
{
Nhittest = htcaption; // The title bar.
}
Return nhittest;
}
After the above processing, if you drag the customer area of the program, the system will think that you are dragging the column and question bar, so that the program can be dragged

In actual application, the following methods can also be used to achieve the same effect.
Uint cpandadlg: onnchittest (cpoint point)
{
// Todo: add your message handler code here and/or call default
Screentoclient (& Point );
 
Crect RC;
Getclientrect (& rc );
 
If (RC. ptinrect (point ))
{
Return htcaption;
}
Else
{
Return cdialog: onnchittest (point );
}
}

Program description:

(1) cpandadlg is a defined dialog box class;

(2) The onnchittest method must be manually added. The method is [view]-[classwizard]. Select the [class info] tab and set [Message filter:]. "window", and then return to the [Message maps] tab, and select "wm_nchttest" in the [messages:] list for the "cpandadlg" class to generate the uint cpandadlg :: onnchittest (cpoint point ).

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.