General changes in the size of the window, the user is dragging the window and frame. Therefore, we can be intercepted in the main window WM_NCHITTEST information in response to its function to determine CWnd:: OnNcHitTest () return value to
HTRIGHT,
HTLEFT,
HTTOP,
HTBOTTOM
One of the four values and, if so, at this time that the user has clicked on one of the four border, at this time we should return to HTCLIENT. In that case, the shape of the mouse will not become horizontal or vertical two-way arrow, the user can not be Drag to change the border depend on the size of the window.
By reading the following class wizard, WM_NCHITTEST did not find this news can only be manually add the mapping information.
In BEGIN_MESSAGE_MAP (CMainFrame, CMDIFrameWnd) under the added
ON_WM_NCHITTEST ()
In the framework of the first category of documents under the
Statement
afx_msg LRESULT OnNcHitTest (CPoint point);
To achieve
LRESULT CMainFrame:: OnNcHitTest (CPoint point)
(
if (CWnd:: OnNcHitTest (point) == HTRIGHT | | CWnd:: OnNcHitTest (point) == HTLEFT | | CWnd:: OnNcHitTest (point) == HTTOP | | CWnd:: OnNcHitTest (point) == HTBOTTOM)
return HTCLIENT;
return CWnd:: OnNcHitTest (point);
)
In that case can not be used to change the size of a mouse, but only four of the restrictions on edge, although not drag the edge of the four, but the four corners. As a result, coupled with
HTTOPLEFT
HTTOPRIGHT
HTBOTTOMLEFT
HTBOTTOMRIGHT
4 this side angle +4 have to die. Ha ha
However, lacking a little bit of, what is lacking
Double-click the top of the window caption that is, when the region will become a small window, and can not return to
How do??
There are ways in the function OnCreate add the following code:
SetWindowLong (m_hWnd, GWL_STYLE, GetWindowLong (m_hWnd, GWL_STYLE) & ~ WS_MAXIMIZEBOX);
This can not maximize button, and double-click the title bar will not be the maximization. Ha ha, you're done ~ ~ ~ |