您好,登录后才能下订单哦!
通常情况下是,按住鼠标不放,按住标题栏区域可拖动窗体,按住客户区不可以拖动窗体
通过添加如下代码,可以实现按住客户区可拖动的操作
LRESULT CTestMfcDlg::OnNcHitTest(CPoint point)
{
UINT nHitTest=CDialogEx::OnNcHitTest(point);
if(nHitTest==HTCLIENT)//如果是客户区
{
nHitTest=HTCAPTION; //则把它当成标题栏
}
return nHitTest;
}
通过如下代码,可改变标题栏高度
void CTestMfcDlg::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
int myCaptionHeight = 50; //标题栏高度
int myLeftBorderWeight =10;
int myRightBorderWeight =10;
int myBottomBorderWeight =10;
if (bCalcValidRects)
{
CRect& rc = (CRect&)lpncsp->rgrc[0];//get the client rectangle
rc.top += myCaptionHeight - GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYDLGFRAME);
rc.left += myLeftBorderWeight - GetSystemMetrics(SM_CYDLGFRAME);
rc.bottom -= myBottomBorderWeight - GetSystemMetrics(SM_CYDLGFRAME);
rc.right -= myRightBorderWeight - GetSystemMetrics(SM_CYDLGFRAME);
}
CDialogEx::OnNcCalcSize(bCalcValidRects,lpncsp);
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。