Programming the status bar of MFC (taking displaying the current time of the system as an example)

Source: Internet
Author: User

First, add the following pane to the string table on the resourse tab, for example, ids_timer clock.

Second, add the identifier to the mainframe app file.
For example:
Static uint indicators [] =
{
Id_separator, // status line indicator
// Id_indicator_caps,
// Id_indicator_num,
// Id_indicator_scrl,
Ids_timer,
};

Again: add the following to the mainframe: oncreate () function:Code:
Ctime T = ctime: getcurrenttime ();
Cstring STR = T. Format ("% H: % m: % s ");
Cclientdc DC (this );
Csize SZ = Dc. gettextextent (STR );

Int Index = 0;
Index = m_wndstatusbar.commandtoindex (ids_timer );
M_wndstatusbar.setpaneinfo (index, ids_timer, sbps_normal, Sz. CX );
M_wndstatusbar.setpanetext (index, STR );

Add the following code to the ontimer () function:

Status Bar programming
ctime T = ctime: getcurrenttime ();
cstring STR = T. format ("% H: % m: % s");
cclientdc (this);
csize SZ = dc. gettextextent (STR);
m_wndstatusbar.setpaneinfo (1, ids_timer, sbps_normal, Sz. CX);
m_wndstatusbar.setpanetext (1, STR);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.