- UID
- 2727
- 积分
- 53
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-2-10
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [FONT=courier new]
- 在dlg的.h文件中加入:
- CStatusBar m_StatusBar1;
- 在dlg的.cpp文件中加入:
- static UINT BASED_CODE indicators[] =
- // static UINT indicators[] =
- {
- //ID_SEPARATOR,
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_USER_STR,
- };
- 然后在.cpp文件OnInitDialog()中加入:
- CRect rcClientOld; // 久客户区RECT
- CRect rcClientNew; // 加入TOOLBAR后的CLIENT RECT
- GetClientRect(rcClientOld); //
- // Called to reposition and resize control bars in the client area of a window
- // The reposQuery FLAG does not really traw the Toolbar. It only does the calculations.
- // And puts the new ClientRect values in rcClientNew so we can do the rest of the Math.
- //重新计算RECT大小
- RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,reposQuery,rcClientNew);
- // All of the Child Windows (Controls) now need to be moved so the Tollbar does not cover them up.
- //所有的子窗口将被移动,以免被TOOLBAR覆盖
- // Offest to move all child controls after adding Tollbar
- //计算移动的距离
- CPoint ptOffset(rcClientNew.left-rcClientOld.left,rcClientNew.top-rcClientOld.top);
- CRect rcChild;
- CWnd* pwndChild = GetWindow(GW_CHILD); //得到子窗口
- while(pwndChild) // 处理所有子窗口
- {//移动所有子窗口
- pwndChild->GetWindowRect(rcChild);
- ScreenToClient(rcChild);
- rcChild.OffsetRect(ptOffset);
- pwndChild->MoveWindow(rcChild,FALSE);
- pwndChild = pwndChild->GetNextWindow();
- }
- CRect rcWindow;
- GetWindowRect(rcWindow); // 得到对话框RECT
- rcWindow.right += rcClientOld.Width() - rcClientNew.Width(); // 修改对话框尺寸
- rcWindow.bottom += rcClientOld.Height() - rcClientNew.Height();
- MoveWindow(rcWindow,FALSE); // Redraw Window
- RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
- // TODO: Add extra initialization here
- m_StatusBar2.CreateEx(this,SBT_TOOLTIPS,WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,AFX_IDW_STATUS_BAR);
- // Set the indicators namely caps and nums lock status
- m_StatusBar2.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT));
- CRect rect;
- GetClientRect(&rect);
- //m_StatusBar.SetPaneInfo(0,ID_INDICATOR_CAPS,SBPS_NORMAL,rect.Width()/2);
- //m_StatusBar.SetPaneInfo(1,ID_INDICATOR_NUM,SBPS_STRETCH ,rect.Width()/2);
- // m_StatusBar.SetPaneInfo(0,ID_INDICATOR_NUM,SBPS_NORMAL ,rect.Width()/3);
- m_StatusBar2.SetPaneInfo(0,ID_INDICATOR_CAPS,SBPS_NORMAL|SBPS_DISABLED,rect.Width()/3);
- m_StatusBar2.SetPaneInfo(1,ID_INDICATOR_NUM,SBPS_NORMAL ,rect.Width()/3);
- m_StatusBar2.SetPaneInfo(2,ID_USER_STR,SBPS_NORMAL ,rect.Width()/3);
- m_StatusBar2.SetPaneText(2,"用户名称", TRUE);
-
- //m_StatusBar.SetPaneInfo(1,ID_USER_STR,SBPS_STRETCH ,rect.Width()/3);
- RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,ID_INDICATOR_NUM);
- m_StatusBar2.GetStatusBarCtrl().SetBkColor(RGB(180,190,190));
- 就加入了状态栏(基于dlg)[/FONT]
复制代码 |
|