三个长期坚持不动摇:卓为VC——界面/窗口——在对话框中使工具栏和状态栏大小随着窗口大小改变

来源:百度文库 编辑:偶看新闻 时间:2024/04/29 03:08:40
void CXXXDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect            rectDlg;
CPaintDC     dc(this);
GetClientRect(rectDlg);
CRect   rectBar;
//工具栏
CToolBar *m_pwndToolBar   =   (CToolBar *)AfxGetApp()->m_pMainWnd->
GetDescendantWindoW(AFX_IDW_TOOLBAR);
m_pwndToolBar->GetClientRect(&rectBar);
//如果不加4,经过若干次最窗口改变大小,则工具栏被完全覆盖
m_pwndToolBar->MoveWindow(0,0,rectDlg.Width(),rectBar.Height()+4);
//状态栏
CStatusBar *m_pwndStatusBar  =   (CStatusBar *)AfxGetApp()->m_pMainWnd->
GetDescendantWindow(AFX_IDW_STATUS_BAR);
m_pwndStatusBar->GetClientRect(&rectBar);
m_pwndStatusBar->MoveWindow(0,cy-rectBar.Height(),rectDlg.Width(),rectBar.Height());
// 绘制对话框背景色
dc.FillSolidRect(rectDlg,RGB(255,255,255));     //设置为白色
}