就是那種滑鼠左鍵按住標題欄移動的。
我想讓它只能在一個小范圍內移動。
求大神指點下
uj5u.com熱心網友回復:
用函式ClipCursoruj5u.com熱心網友回復:
WM_GETMINMAXINFOThe WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.
WM_GETMINMAXINFO
lpmmi = (LPMINMAXINFO) lParam; // address of structure
Parameters
lpmmi
Value of lParam. Pointer to a MINMAXINFO structure that contains the default maximized position and dimensions, and the default minimum and maximum tracking sizes. An application can override the defaults by setting the members of this structure.
Return Values
If an application processes this message, it should return zero.
Remarks
The maximum tracking size is the largest window size that can be produced by using the borders to size the window. The minimum tracking size is the smallest window size that can be produced by using the borders to size the window.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.
See Also
Windows Overview, Window Messages, MoveWindow, SetWindowPos, MINMAXINFO
uj5u.com熱心網友回復:
CWnd::OnWindowPosChangeduj5u.com熱心網友回復:
void CxxxxxDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
CDialog::OnMoving(fwSide, pRect);
// TODO: Add your message handler code here
#if 1
#define MOSTLEFT 100
#define MOSTTOP 100
#define MOSTRIGHT 1050
#define MOSTBOTTOM 750
CRect rect;
GetWindowRect(&rect);
afxDump << *pRect << "\n";
if(pRect->left <=MOSTLEFT)
{
pRect->left=MOSTLEFT;
pRect->right=MOSTLEFT+rect.Width();
}
if(pRect->right >=MOSTRIGHT)
{
pRect->right=MOSTRIGHT;
pRect->left=MOSTRIGHT-rect.Width();
}
if(pRect->top <=MOSTTOP)
{
pRect->top=MOSTTOP;
pRect->bottom=MOSTTOP+rect.Height();
}
if(pRect->bottom >=MOSTBOTTOM)
{
pRect->bottom=MOSTBOTTOM;
pRect->top=MOSTBOTTOM-rect.Height();
}
#endif
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/126416.html
標籤:基礎類
