Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show both icon and text on button on mfc?

Tags:

c++

mfc

Code Used:

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 Code show neither showing image nor showing text.

like image 302
Suri Avatar asked Aug 13 '10 08:08

Suri


3 Answers

You might use CMFCButton if you are using VS 2008 SP1 or higher.

like image 172
Javier De Pedro Avatar answered Nov 09 '22 07:11

Javier De Pedro


BM_SETIMAGE is not a button style, but a message which is sent to the window in order to set a bitmap. What you probably want is the BS_BITMAP style. Unfortunately as far as I know, it is not possible to have both text and a bitmap on a standard button. But you should find plenty of working implementations of a custom button class on sites like codeguru or codeproject.

like image 44
humbagumba Avatar answered Nov 09 '22 07:11

humbagumba


BS_ICON and BS_BITMAP must be both unset to enable icon and text on the same button.

See https://msdn.microsoft.com/en-us/library/bb761822(VS.85).aspx

like image 40
Bogey Jammer Avatar answered Nov 09 '22 08:11

Bogey Jammer