如何加?最好有些代码提示.

解决方案 »

  1.   

    可以加
    m_btn.SetBitmaps(IDB_BITMAP1,RGB(0,0,0));
      

  2.   

    这是加资源文件中的图片,那如何加载(jpg,bmp,gif)文件呢?
      

  3.   

    可以将图片加载到内存转化为HBITMAP类型的.
      

  4.   

    其实可以自己写一个类的,重载CBitmapButton的DrawItem函数
    Blog里还没有写,sorry
      

  5.   

    BOOL CBtnPng::LoadBitmaps(LPCTSTR lpszPngResource, LPCTSTR lpszPngResourceSel, LPCTSTR lpszPngResourceFocus, LPCTSTR lpszPngResourceDisabled)
    {
    // delete old bitmaps (if present)
    m_bitmap.DeleteObject();
    m_bitmapSel.DeleteObject();
    m_bitmapFocus.DeleteObject();
    m_bitmapDisabled.DeleteObject();

    CxImage image(lpszPngResource, CXIMAGE_FORMAT_PNG);
    m_hBitmap = image.MakeBitmap(GetDC()->m_hDC);
    if (!m_hBitmap)
    {
    TRACE0("Failed to load bitmap for normal image.\n");
    return FALSE;   // need this one image
    }
    else
    m_bitmap.Attach(m_hBitmap);

    BOOL bAllLoaded = TRUE;
    if (lpszPngResourceSel != NULL)
    {
    CxImage imageSel(lpszPngResourceSel, CXIMAGE_FORMAT_PNG);
    m_hBitmapSel = imageSel.MakeBitmap(GetDC()->m_hDC);
    if (!m_hBitmapSel)
    {
    return FALSE;   
    }
    else
    m_bitmapSel.Attach(m_hBitmapSel);
    }
    if (lpszPngResourceFocus != NULL)
    {
    CxImage imageFocus(lpszPngResourceFocus, CXIMAGE_FORMAT_PNG);
    m_hBitmapFocus = imageFocus.MakeBitmap(GetDC()->m_hDC);
    if (!m_hBitmapFocus)
    {
    return FALSE;   
    }
    else
    m_bitmapFocus.Attach(m_hBitmapFocus);

    }
    if (lpszPngResourceDisabled != NULL)
    {
    CxImage imageDisabled(lpszPngResourceDisabled, CXIMAGE_FORMAT_PNG);
    m_hBitmapDisabled = imageDisabled.MakeBitmap(GetDC()->m_hDC);
    if (!m_hBitmapDisabled)
    {
    return FALSE;   
    }
    else
    m_bitmapDisabled.Attach(m_hBitmapDisabled);
    }
    return bAllLoaded;

    }