Windows interface: simple application of the status bar

Source: Internet
Author: User

1. After creating a single document project, add the display name to the string table member in the resource bar:

Ids_status
Ids_timecost
Ids_itemsscanned

2. Modify the indicators definition in mainfrm. cpp:

Static uint indicators [] =
{
Id_separator, // status line indicator
Ids_status,
Ids_timecost,
Ids_itemsscanned,
// Id_indicator_caps,
// Id_indicator_num,
// Id_indicator_scrl,
};

3. Create the code in cmainframe: oncreate () and add the setting code:

Int cmainframe: oncreate (maid)
{
...

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
}
// Set the information display position of the status bar
M_wndstatusbar.setpaneinfo (m_wndstatusbar.commandtoindex (ids_status), ids_status, sbps_normal, 100 );
M_wndstatusbar.setpaneinfo (m_wndstatusbar.commandtoindex (ids_timecost), ids_timecost, sbps_normal, 150 );
M_wndstatusbar.setpaneinfo (m_wndstatusbar.commandtoindex (ids_itemsscanned), ids_itemsscanned, sbps_normal, 150 );

Return 0;
}

4. Modify the displayed value string in the message processing function:

Lresult cmainframe: onmsggotfilestatus (wparam, lparam)
{
Csd_filescannerview * pview = (csd_filescannerview *) getactiveview ();
Pview-> onmsggotfilestatus (wparam, lparam );

Cfilestatus filestatus (* (cfilestatus *) lparam );
M_wndstatusbar.setpanetext (0, filestatus. m_szfullname );
Cstring STR;
Str. Format (_ T ("time cost: % u. % 03d sec ")
, (Gettickcount ()-m_dwstarttick)/1000.
, (Gettickcount ()-m_dwstarttick) % 1000
);
Int iindex = m_wndstatusbar.commandtoindex (ids_timecost );
M_wndstatusbar.setpanetext (iindex, STR );

Return 0;
}

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.