public:
CReBar m_ReBar;
CMyDlgBar m_DlgBar;
afx_msg void OnSize(UINT nType, int cx, int cy);
。。。。。。。。
BOOL CPageWeb::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
m_ReBar.Create(this, NULL, WS_CHILD | WS_VISIBLE | RBS_AUTOSIZE, AFX_IDW_REBAR);
m_DlgBar.Create(IDD_DLGBAR, this);
CWnd* hwnd = AfxGetMainWnd();
CRect rt;
hwnd->GetClientRect(&rt);
ScreenToClient(&rt);
REBARBANDINFO rbi = { 0 };
rbi.cbSize = sizeof(REBARBANDINFO);
rbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_STYLE | RBBIM_ID | RBBIM_SIZE;
rbi.fStyle = RBBS_VARIABLEHEIGHT | RBBS_GRIPPERALWAYS |CBRS_BORDER_TOP | RBBS_NOGRIPPER; //
rbi.hwndChild = (HWND)m_DlgBar;
m_ReBar.GetReBarCtrl().InsertBand(0, &rbi);
m_ReBar.SetWindowPos(NULL, 1, 0, rt.Width()-1, 30, SWP_SHOWWINDOW);
CRect _rt;
m_ReBar.GetClientRect(&_rt);
_rt.left += 0;
_rt.top += 0;
_rt.right = rt.Width() - 1;
_rt.bottom = 28;
m_DlgBar.MoveWindow(&_rt);
m_DlgBar.ShowWindow(SW_SHOW);
return TRUE; // return TRUE unless you set the focus to a control
}
程序能够正常运行
现在需要在窗口改变大小时,工具条也跟随调整,但是不知道该怎么写:
void CPageWeb::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
Invalidate();//更新窗口
}
初学者求老狮帮忙。