MFC 对话框 OnNcHitTest 消息拖动无标题窗口大小 经典

herryjin 2008-10-16 10:24:42
我在MFC 对话框OnNcHitTest 消息中

LRESULT CdragtestDlg::OnNcHitTest(CPoint point)
{

CRect rc;
GetClientRect(&rc);

CRect rc_bottom_right;
rc_bottom_right.left =rc.Width()-5;
rc_bottom_right.right = rc.right;
rc_bottom_right.top = rc.Height() -5;
rc_bottom_right.bottom = rc.bottom;

ClientToScreen(&rc_bottom_right);



//如果在右下角就可以拖动窗口大小
if( rc_bottom_right .PtInRect( point ) )
{
return HTBOTTOMRIGHT;
}
else
{
return HTCLIENT;
}
}


其中 窗口 style = pop border = none;
在delphi 和C++ builder中都是可以的

但是事实上不能改变窗口大小

请高人指教 谢谢
1
...全文
611 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
palmax 2008-10-16
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zhoujianhei 的回复:]
CRect rc;
//GetClientRect(&rc);
GetWindowRect(&rc);
[/Quote]

OnNcHitTest(CPoint point)里的point参数的值是屏幕坐标,看MSDN就明白了
dandycheung 2008-10-16
  • 打赏
  • 举报
回复
自己实现对窗口的位置和大小进行改变的功能:http://sluttery.spaces.live.com/blog/cns!3569FEA80C717FD4!3531.entry?wa=wsignin1.0
zhoujianhei 2008-10-16
  • 打赏
  • 举报
回复
CRect rc;
//GetClientRect(&rc);
GetWindowRect(&rc);
herryjin 2008-10-16
  • 打赏
  • 举报
回复
最终的目的是想通过贴图,自制皮肤窗口,
因此将原来的对话框设置成无边框
->实现右下角鼠标左键按下时,拖动窗口大小
herryjin 2008-10-16
  • 打赏
  • 举报
回复
我的本意是想:当鼠标在窗口的右下角时,
可以拖动窗口大小

//如果在右下角就可以拖动窗口大小
if( rc_bottom_right .PtInRect( point )

dirdirdir3 2008-10-16
  • 打赏
  • 举报
回复
如果不是你要处理的话,返回调用缺省的cdialog::OnNcHitTest(CPoint point)
wgm001 2008-10-16
  • 打赏
  • 举报
回复
帮顶,没看明白楼主的意思...
cnzdgs 2008-10-16
  • 打赏
  • 举报
回复
同上,此消息是屏幕坐标,要用GetWindowRect。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧