purpleendurer 原创
2005.11.26 第1版
当用户缩放窗口时,我们要调整窗口中的各个控件的位置。
我们对WM_SIZE消息进行处理,代码如下:
void CSwfPlayerDlg::OnSize(UINT nType, int cx, int cy)
{
//CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if (nType != SIZE_MINIMIZED) //如果窗口不是最小化则进行调整
{
RECT DlgRect, BtnRect, StatusBarRect;
GetWindowRect(&DlgRect); //取当前窗口的Rect,此DlgRect用于重新设置flash
ScreenToClient(&DlgRect);
::MoveWindow(m_hStatusWindow,0, 0, 0, 0, true);//重新设置状态栏
::GetWindowRect(m_hStatusWindow, &StatusBarRect);//取状态栏的Rect
ScreenToClient(&StatusBarRect);
m_BtnOpen.GetWindowRect(&BtnRect);//取命令按钮的坐标
ScreenToClient(&BtnRect);
DlgRect.top = BtnRect.bottom + 10;//flash的左上角
DlgRect.bottom = StatusBarRect.top;//flash的右下角
m_SwfBox.MoveWindow(&DlgRect);
}
}