Click here to Skip to main content
16,006,822 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: display a image on button Pin
Amit Agarrwal29-Jun-06 0:29
Amit Agarrwal29-Jun-06 0:29 
GeneralRe: display a image on button Pin
Hamid_RT29-Jun-06 0:35
Hamid_RT29-Jun-06 0:35 
GeneralRe: display a image on button Pin
ovidiucucu29-Jun-06 0:58
ovidiucucu29-Jun-06 0:58 
GeneralRe: display a image on button Pin
Hamid_RT29-Jun-06 1:29
Hamid_RT29-Jun-06 1:29 
GeneralRe: display a image on button Pin
Hamid_RT29-Jun-06 1:43
Hamid_RT29-Jun-06 1:43 
GeneralRe: display a image on button Pin
ovidiucucu29-Jun-06 2:04
ovidiucucu29-Jun-06 2:04 
GeneralRe: display a image on button Pin
Hamid_RT29-Jun-06 2:32
Hamid_RT29-Jun-06 2:32 
AnswerRe: display a image on button Pin
ovidiucucu29-Jun-06 0:55
ovidiucucu29-Jun-06 0:55 
You have to:

  • be sure the button has BS_BITMAP style; you can do this in the resource editor or by calling ModifyStyle.
  • call ::LoadImage Windows API function to load the bitmap fromthe file
  • call CButton::SetBitmap

Here is an example:

BOOL CMyDialog::OnInitDialog()
{
   CDialog::OnInitDialog();
   LoadButtonBitmapImage(IDC_BUTTON3, _T("c:\\mybutton.bmp"));

// ...
}
// NOTE: this is just an example - to be easier to read, no error is handled
void  CMyDialog::LoadButtonBitmapImage(UINT nButtonResID,
                                       LPCTSTR pszBitmapFile)
{
   CButton* pButton = (CButton*)GetDlgItem(nButtonResID);
   // be sure the button has BS_BITMAP style
   pButton->ModifyStyle(BS_ICON, BS_BITMAP);
   // load bitmap from file
   HBITMAP hBitmap = (HBITMAP)::LoadImage(NULL,
                                          pszBitmapFile,
                                          IMAGE_BITMAP, 0, 0,
                                          LR_DEFAULTCOLOR|LR_LOADFROMFILE);
   // set the button bitmap
   pButton->SetBitmap(hBitmap);
}


Ovidiu Cucu
Microsoft MVP - Visual C++
GeneralRe: display a image on button Pin
Amit Agarrwal29-Jun-06 1:29
Amit Agarrwal29-Jun-06 1:29 
GeneralRe: display a image on button [modified] Pin
Hamid_RT29-Jun-06 1:45
Hamid_RT29-Jun-06 1:45 
GeneralRe: display a image on button Pin
Amit Agarrwal29-Jun-06 1:54
Amit Agarrwal29-Jun-06 1:54 
GeneralRe: display a image on button Pin
Hamid_RT29-Jun-06 2:00
Hamid_RT29-Jun-06 2:00 
GeneralRe: display a image on button Pin
ovidiucucu29-Jun-06 2:09
ovidiucucu29-Jun-06 2:09 
GeneralRe: display a image on button Pin
Amit Agarrwal29-Jun-06 2:11
Amit Agarrwal29-Jun-06 2:11 
GeneralRe: display a image on button Pin
ovidiucucu29-Jun-06 2:11
ovidiucucu29-Jun-06 2:11 
GeneralRe: display a image on button Pin
Amit Agarrwal29-Jun-06 3:02
Amit Agarrwal29-Jun-06 3:02 
GeneralRe: display a image on button Pin
Amit Agarrwal29-Jun-06 20:44
Amit Agarrwal29-Jun-06 20:44 
GeneralRe: display a image on button Pin
Amit Agarrwal29-Jun-06 21:11
Amit Agarrwal29-Jun-06 21:11 
AnswerRe: display a image on button Pin
David Crow29-Jun-06 2:57
David Crow29-Jun-06 2:57 
QuestionActiveX issue Pin
Nader Elshehabi28-Jun-06 23:41
Nader Elshehabi28-Jun-06 23:41 
AnswerRe: ActiveX issue Pin
bob1697229-Jun-06 1:59
bob1697229-Jun-06 1:59 
GeneralRe: ActiveX issue Pin
Nader Elshehabi29-Jun-06 3:24
Nader Elshehabi29-Jun-06 3:24 
GeneralRe: ActiveX issue Pin
bob1697229-Jun-06 4:32
bob1697229-Jun-06 4:32 
GeneralRe: ActiveX issue Pin
Nader Elshehabi29-Jun-06 5:13
Nader Elshehabi29-Jun-06 5:13 
Questiontwo calsses Pin
ashish dogra28-Jun-06 23:28
ashish dogra28-Jun-06 23:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.