下面是限制对话框的移动范围方法
void CxxxxDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
CDialog::OnMoving(fwSide, pRect);
// TODO: Add your message handler code here
#if 1
#define MOSTLEFT 100
#define MOSTTOP 80
#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
}
本文介绍了一种使用MFC编程的方法来限制对话框在屏幕上的移动范围,确保其不会超出预设的边界。
4310

被折叠的 条评论
为什么被折叠?



