愚蠢的问题

来源:互联网 发布:linux mint 主题 编辑:程序博客网 时间:2024/04/28 11:00
CRect rt;
this->GetWindowRect (&rt);
ScreenToClient(&rt);
this->m_Btn7.MoveWindow (rt.left ,rt.top ,(4/7)*rt.Width (),(6/10)*rt.Height (),TRUE);

这段代码运行之后m_Btn7消失,竟是由于(4/7)*rt.Width ()计算下来为零,因为rt.Width ()返回值为int,那么(4/7)被强制转化为int即0。

改进方法如下:
this->m_Btn7.MoveWindow (rt.left ,rt.top ,(4/7.0)*rt.Width (),(6/10.0)*rt.Height (),TRUE);
原创粉丝点击