Dynamically change the toolbar button icon

Source: Internet
Author: User

In this example, the dynamically changed toolbar button icon is stored in the toolbar resource whose ID is idr_toolbar_shell and can be used as a bitmap resource.

Cimagelist * m_imglist1;

M_imglist1 = (m_wndtoolbar.gettoolbarctrl (). getimagelist ();

Int A = m_imglist1-> getimagecount ();

Cbitmap CBMP;

Bitmap BMP;

CBMP. loadbitmap (idr_toolbar_shell );

CBMP. getbitmap (& BMP );

M_imglist1-> Add (& CBMP, RGB (192,192,192 ));

(M_wndtoolbar.gettoolbarctrl (). setimagelist (m );

M_imglist1-> detach ();

M_imglist1 = NULL;

CBMP. deleteobject ();

The above Code adds bitmap in idr_toolbar_shell to the image list of m_wndtoolbar, which can also be implemented through other methods.

Next, you can dynamically change the icon of a button. For example, change the icon ID id_menuitem32780 to the second icon in idr_toolbar_shell:

M_wndtoolbar.setbuttoninfo (m_wndtoolbar.commandtoindex (id_menuitem32780), id_menuitem32780, tbbs_button, A + 1 );

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.