主题 |
1. 2. 3. 4. 5. |
代码::创建状态栏 |
//手动添加3个ICON /////////////////////////////////////////////////////////////////////////////
// CProject01Dlg dialog
//
// class CProject01Dlg : public
CDialog // {
// // Construction
// public:
// CProject01Dlg(CWnd* pParent = NULL);
// standard constructor CStatusBar m_statusBar;
// BOOL CProject01Dlg::OnInitDialog()
// TODO: Add extra initialization
here BOOL bRec = m_statusBar.Create( this );
UINT nIDS[ 3 ] =
{0x1001,0x1002,0x1003}; bRec = m_statusBar.SetIndicators(nIDS, 9 );
m_statusBar.SetPaneInfo( 0 ,nIDS[ 0 ],SBPS_NORMAL, 100 );
m_statusBar.SetPaneInfo( 1 ,nIDS[ 1 ],SBPS_NORMAL, 200 );
m_statusBar.SetPaneInfo( 2 ,nIDS[ 2 ],SBPS_NORMAL, 32565 );
m_statusBar.SetPaneText( 0 , "提示:" );
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0 );
//添加OnSize消息
void CProject01Dlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code
here RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0 );
}
//即时显示鼠标所放在菜单的的文字
//在类向导中添加 1 个WindowProc消息
LRESULT
CProject01Dlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
// TODO: Add your specialized code here and/or call
the base class if (message == WM_MENUSELECT)
{
// OnHotMenu(LOWORD(wParam));
CMenu
* pMenu = GetMenu(); if
(pMenu != NULL) {
CString
strText; pMenu
- > GetMenuString(( int )LOWORD(wParam),strText,MF_BYCOMMAND); m_statusBar.SetPaneText( 1 ,strText);
}
}
return CDialog::WindowProc(message, wParam, lParam);
} 效果图: |
Code:: |
//Show
void CMainFrame::OnShow()
{
if(!m_wndStatusBar.IsWindowVisible())
{
m_wndStatusBar.ModifyStyle(0, WS_VISIBLE,SWP_FRAMECHANGED);
}
//使状态栏状态生效
SendMessage(WM_SIZE);
}
//Hide
void CMainFrame::OnHide()
{
if(m_wndStatusBar.IsWindowVisible())
{
m_wndStatusBar.ModifyStyle(WS_VISIBLE, 0,SWP_FRAMECHANGED);
}
//使状态栏状态生效
SendMessage(WM_SIZE);
}
效果图: |