How to change color of a status bar

Submitted by date of submission user level 

Ksheeraj Kumud  Sept 19, 2000 Beginner 

      

In order to change Color of your status bar do the following: Here is few lines code which you have to look. this Example Assume that you Have Standard MFC App. and following member variable is Defined.

protected: // control bar embedded members

CStatusBar m_wndStatusBar;

CToolBar m_wndToolBar;

 inside your CMainFrameClass 

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)

return -1;

if (!m_wndToolBar.Create(this) ||

!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))

{

TRACE0("Failed to create toolbar\n");

return -1; // fail to create

}

if (!m_wndStatusBar.Create(this) ||

!m_wndStatusBar.SetIndicators(indicators,

sizeof(indicators)/sizeof(UINT)))

{

TRACE0("Failed to create status bar\n");

return -1; // fail to create

}

// TODO: Remove this if you don't want tool tips or a resizeable toolbar

m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |

CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

// TODO: Delete these three lines if you don't want the toolbar to

// be dockable

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&m_wndToolBar); 

//Insert These Lines in order to change Color of status Bar.

//If you put these lines it will change your Status Bar Background color to Red.

CStatusBarCtrl &pStatusBarCtrl = m_wndStatusBar.GetStatusBarCtrl();

pStatusBarCtrl.SetBkColor(RGB(255,0,0));

return 0;

}

 

 

About the Author:

Section manager of ATL/COM and moderator of forums. Ksheeraj has around 4 years of programming experience in VC++, MFC, VB, and ATL/COM. Ksheeraj is currently engaged with Kla-tencor, a CA based company. He can be reached at Ksheeraj. Ksheeraj's background is Masters in Computer Science and Applications and B.Sc. maths.