关于OnSize()事件中控件的移动,有没有好的方法?
关于OnSize()事件中控件的移动,我一般用下面的方法:
CDialog::OnSize(nType, cx, cy);
ReSetControls(cx,cy);//使用MoveWindow一个一个得移动控件
Invalidate(TRUE);
GetRects();//得到所有控件的新位置
因为在ReSetControls中有很多控件需要移动,所以窗口在改变大小时,控间的移动地先后顺序很明显,延迟时间也比较长(因为控件实在是不少),很不好看。
有没有其他的方法,能够让控件看上去好像一起移动??
问题点数:10、回复次数:4Top
1 楼over1982(小处男9527)回复于 2005-06-02 10:52:51 得分 5
按照控件之间的比例来
rList.left = 0;
rList.top = (rList.bottom/2-rList.bottom/5);
rStat.bottom = rList.top * 4/5;
rStat.top = rStat.bottom - 20 ;
rStat.right = rList.right * 7/8 ;
rStat.left = rStat.right - 69;Top
2 楼cdeee(亦难)回复于 2005-06-02 13:43:54 得分 0
你这样是因为 OnSize 处理得太过频繁造成的,你不因该每次调用 OnSize 的时候都移动子控件,而是应该在窗口尺寸调整完毕后在进行移动。Top
3 楼phoniex()回复于 2005-07-11 15:55:50 得分 0
关注
如何捕捉 在Sizing结束(鼠标左键弹起)时触发的消息?
或者,这个消息 是什么
Top
4 楼CodeKey()回复于 2005-07-13 09:34:07 得分 5
The WM_SIZE message is sent to a window after its size has changed.
The WM_SIZING message is sent to a window that the user is resizing. By processing this message, an application can monitor the size and position of the drag rectangle and, if needed, change its size or position.
//可以这样试试:
OnSize()
{
ShowWindow(SW_HIDE);
ReSetControls(cx,cy);
ShowWindow(SW_SHOW);
}Top




