Using an icon as a button's face
I have a class derived from CDaoRecordView with two buttons on it. I want to use icons I made as the faces of these buttons. In my CMyRecordView::OnInitialUpdate() I have the following code:
CButton *curButton = (CButton*)GetDlgItem(IDC_BUTTON_CV_ADD);
curButton->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_CV_ADD)));
// curButton->UpdateData();
curButton = (CButton*)GetDlgItem(IDC_BUTTON_CV_SUB);
curButton->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_CV_SUB)));
// curButton->UpdateData();
But when I run my program I have two blank buttons. How do I get the icons to show up correctly?
Thanks,
Erik
Re: Using an icon as a button's face
Did you check appropriate style of the button in resource editor? It must be set to Icon.
Re: Using an icon as a button's face
Re: Using an icon as a button's face
Got it. I have overlooked something.
Change:
curButton->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_CV_ADD)));
To:
curButton->SetIcon(::LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON_CV_ADD)));