MFC button three figures three states

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/chen1083376511/article/details/89949736

Use:
1. Suppose you create a new project called CButtonTest.
2. called "ControlButton" header and source files added to the project in CButtonTest.
3. If the reference ControlButton.h CButtonTestDlg.h, the #inlcude "ControlButton.h", to be drawn on the control button to add a variable, the control variable and declaration, to replace "CButton" type into CControlButton type. For example: "CButton m_btn;" replace "CControlButton m_btn;"
4. The general picture bmp placed res folder or elsewhere can, anyway, after the compiler will convert bmp file to binary data, do not care about the existence of the path .
5. CButtonTestDlg.cpp's OnInitDialog () function in the control is initialized.
Code as follows:
// or the button properties, it is set to custom drawing, i.e. "Owner Draw" is set to True.
The GetDlgItem (IDC_BUTTON1) -> ModifyStyle (0, the BS_OWNERDRAW, 0);
m_btn.SetBitmapId (IDB_BITMAP3, IDB_BITMAP2, IDB_BITMAP4, IDB_BITMAP3);
SetBitmapId function parameters:
SetBitmapId (NOVER int, int nNormal, nPressed int, int nFocus)

Source connection: https://down.51cto.com/data/2461181 

effect:

Guess you like

Origin blog.csdn.net/chen1083376511/article/details/89949736