VC在对话框中使工具栏和状态栏大小随着窗口大小改变
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)); //设置为白色
}
- 上一篇:VC驱动监控进程的创建
- 下一篇:在VC++中建立自定义数据库类