I want it to move only in a small scope,
Under the great god give directions
CodePudding user response:
With the function ClipCursorCodePudding user response:
WM_GETMINMAXINFOThe WM_GETMINMAXINFO message is sent to a window when The size or The position of The window is about to change. An application can use this message to override The window 's default maximized The size and position, or its default minimum or maximum tracking The size.
WM_GETMINMAXINFO
Lpmmi=(lParam LPMINMAXINFO);//address of structure
The Parameters
Lpmmi
Value of lParam. Pointer to a MINMAXINFO structure that contains the default maximized the position and dimensions, and the default minimum and maximum tracking sizes. An application can override the defaults by setting the members of this structure.
The Return Values
If an application the processes this message, it should return zero.
Few
The maximum tracking The size is The largest window size that can be produced by using The borders to size The window. The minimum tracking The 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, the Overview Window Messages, MoveWindow SetWindowPos, MINMAXINFO
CodePudding user response:
CWnd: : OnWindowPosChangedCodePudding user response:
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 the rect.
GetWindowRect (& amp; The rect);
AfxDump & lt; <* pRect & lt; <"\ n";
If (pRect - & gt; Left & lt;=MOSTLEFT)
{
PRect - & gt; Left=MOSTLEFT;
PRect - & gt; Right.=MOSTLEFT + the rect Width ();
}
If (pRect - & gt; Right & gt;=MOSTRIGHT)
{
PRect - & gt; Right=MOSTRIGHT;
PRect - & gt; Left=MOSTRIGHT - the rect. Width ();
}
If (pRect - & gt; Top & lt;=MOSTTOP)
{
PRect - & gt; Top=MOSTTOP;
PRect - & gt; Bottom=MOSTTOP + the rect. Height ();
}
If (pRect - & gt; Bottom & gt;=MOSTBOTTOM)
{
PRect - & gt; Bottom=MOSTBOTTOM;
PRect - & gt; Top=MOSTBOTTOM - the rect. Height ();
}
# endif
}