A picture display MFC suspension, pressed, an initial state

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

Use:
1. Suppose you create a new project called CButtonTest.
2. called "PicButton" header and source files added to the project in CButtonTest.
3. If the reference PicButton.h CButtonTestDlg.h, the #inlcude "PicButton.h", push button control to add variables to be drawn, the control and states
when variable to replace "CButton" type into CPicButton type. For example: "CButton m_btn;" replace "CPicButton 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 road
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.LoadImg (IDB_BITMAP1, 30, 27);
LoadImg function parameters:
1. Resource ID
2. Image display width
3 to display images of high
resource links: HTTPS : //down.51cto.com/data/2461130 

Renderings:

Guess you like

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