Creation of the status bar: CStatusBar object creation Call the CREATE function creates a status bar
if (!m_wndstatusbar.create (this))
{
TRACE0 ("Failed to create status bar\n");
return-1; Fail to create
}
Call SetIndicators to append a string resource ID to each indicator:
M_wndstatusbar.setindicators (indicators, sizeof (indicators)/sizeof (UINT));
Static UINT indicators[] =
{
Id_separator,//Status line indicator
Id_indicator_caps,
Id_indicator_num,
ID_INDICATOR_SCRL,
Ids_timer,
Ids_progress,
...//Here the string resource is added to the status bar
};
Added in the frame WM_PAINT message corresponding function OnPaint
SetTimer (1000,1000,null);
To capture the Wm_timer message, add the following code to the OnTimer function
CTime time=ctime::getcurrenttime ();//Returns a CTime object through a static method
CString Str=time. Format ("%h:%m:%s"); Format time to Str
CCLIENTDC DC (this); Create a DC for a framework class
CSize SIZE=DC. GetTextExtent (str); Get the dimensions that appear on the screen in a string
int index =m_wndstatusbar.commandtoindex (ids_timer); Get an index by ID
M_wndstatusbar.setpaneinfo (INDEX,IDS_TIMER,SBPS_NORMAL,SIZE.CX); Set the width of the indicator
M_wndstatusbar.setpanetext (INDEX,STR); Sets the text of the specified index indicator
MFC single-document taskbar adding system time