Reputation: 97
I wanted to create CMFCButton dynamically at runtime (Icon with Text on the button). The icon is created successfully but I wanted to display the icon above text.
I want to implement "Image on Top" property found in Resource Editor for the button.
My Code:
CMFCButton* appButton = new CMFCButton;
appButton->Create( _T("MfcButton1"), WS_CHILD | WS_VISIBLE, CRect(10, 10, 70, 50), this );
appButton->SetIcon( sfi.hIcon );
Upvotes: 3
Views: 1778
Reputation: 3190
(according to the "NewControls" MFC sample).
To set an image in a CMFCButton use CMFCButton::SetImage. To set the image above (or below) the text you can use the undocumented variable m_bTopImage
appButton->m_bTopImage = TRUE;
FYI: the complete samples can be downloaded from : http://www.microsoft.com/en-us/download/details.aspx?id=5718
Upvotes: 4