Reputation: 27
I'm new to MFC, How can I customize buttons in such a way that
After browsing the internet I got to know that we need to override DrawItem method once the button is created with BS_OWNERDRAW style, How can i override DrawItem Method?
( MFC application using SDI,)
Upvotes: 0
Views: 449
Reputation: 1566
In Global Variable:
CButton button;
In DoDataExchange:
DDX_Control(pDX, IDC_BUTTON, button);
where IDC_button is declared on your dialog resource and pDX is your CDataExchange
Where you want to add image:
button.SetBitmap((HBITMAP)LoadImage(AfxGetApp()->m_hInstance,
MAKEINTRESOURCE(IDB_BITMAP1),
IMAGE_BITMAP, 16, 16, LR_COLOR));
where m_hInstance is your CWinApp, IDB_BITMAP1 is a resource picture.
For text:
button.SetWindowTextW(_T("TEXT"));
Upvotes: 1