How to show icon and text on a button on mfc?

Used code:

m_pButton->Create(L"ABC", WS_CHILD | WS_VISIBLE| BM_SETIMAGE,CRect(0,0,100,100),this,ID_BUTTON1);

m_pButton->SetIcon(::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON1)));

// above The code does not show image display or text display.

+3
source share
4 answers

BM_SETIMAGE is not a button style, but a message that is sent to a window to set a bitmap. Maybe you need the BS_BITMAP style. Unfortunately, as far as I know, it is impossible to use both text and a bitmap on a standard button. But you must find many working implementations of the custom button class on sites such as codeguru or codeproject.

+2
source

You can use CMFCButton if you use VS 2008 SP1 or higher.

+3

WPF . .

0

You can override the method DrawItemin CButton. See the following links for more information:

CButton :: DrawItem

Hand Drawn Button Owner - Step by Step

0
source

Source: https://habr.com/ru/post/1759481/


All Articles