龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC在对话框中使工具栏和状态栏大小随着窗口大小改变

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
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 = (C

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));     //设置为白色
}

收藏文章
表情删除后不可恢复,是否删除
取消
确定
图片正在上传,请稍后...
评论内容为空!
还没有评论,快来抢沙发吧!
按钮 内容不能为空!
立刻说两句吧! 查看0条评论
精彩图集

赞助商链接