Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CBitmap, CButton HBIMAP and more..

CBitmap, CButton HBIMAP and more..

Scheduled Pinned Locked Moved C / C++ / MFC
comgraphicsquestionlearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Remi Morin
    wrote on last edited by
    #1

    This function do not work, why... CSpecialControl is derived from CWnd BOOL CSpecialControl::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { BOOL Oktemp; //after this line hbm is null, IDB_BITMAP1 is a valid resource... //why it does'nt work? How I am supposed to use it? HBITMAP hbm = ::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP1)); //this work CBitmap MyBitmap; MyBitmap.LoadBitmap( IDB_BITMAP1); //this work Oktemp = CWnd::Create (NULL,_T(""),WS_CHILD|WS_CLIPCHILDREN, rect, pParentWnd, nID ,pContext); //this work, I can see the button and catch his command Oktemp &= m_cBouton_1.Create (_T(""),WS_CHILD |BS_PUSHBUTTON|BS_BITMAP|WS_VISIBLE ,CRect(0,0,100,100),this,IDC_BUTTONGAUCHE); //and the bitmap is never displayed on the button.... //do I have to set a different Style ti my button? m_cBouton_1.SetBitmap(MyBitmap); m_cBouton_1.ShowWindow(SW_SHOWNORMAL); return Oktemp; } Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

    L M 2 Replies Last reply
    0
    • R Remi Morin

      This function do not work, why... CSpecialControl is derived from CWnd BOOL CSpecialControl::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { BOOL Oktemp; //after this line hbm is null, IDB_BITMAP1 is a valid resource... //why it does'nt work? How I am supposed to use it? HBITMAP hbm = ::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP1)); //this work CBitmap MyBitmap; MyBitmap.LoadBitmap( IDB_BITMAP1); //this work Oktemp = CWnd::Create (NULL,_T(""),WS_CHILD|WS_CLIPCHILDREN, rect, pParentWnd, nID ,pContext); //this work, I can see the button and catch his command Oktemp &= m_cBouton_1.Create (_T(""),WS_CHILD |BS_PUSHBUTTON|BS_BITMAP|WS_VISIBLE ,CRect(0,0,100,100),this,IDC_BUTTONGAUCHE); //and the bitmap is never displayed on the button.... //do I have to set a different Style ti my button? m_cBouton_1.SetBitmap(MyBitmap); m_cBouton_1.ShowWindow(SW_SHOWNORMAL); return Oktemp; } Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      > //why it does'nt work? How I am supposed to use it? > HBITMAP hbm = ::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP1)); Use AfxGetInstanceHandle instead of NULL as the first parameter

      1 Reply Last reply
      0
      • R Remi Morin

        This function do not work, why... CSpecialControl is derived from CWnd BOOL CSpecialControl::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { BOOL Oktemp; //after this line hbm is null, IDB_BITMAP1 is a valid resource... //why it does'nt work? How I am supposed to use it? HBITMAP hbm = ::LoadBitmap(NULL,MAKEINTRESOURCE(IDB_BITMAP1)); //this work CBitmap MyBitmap; MyBitmap.LoadBitmap( IDB_BITMAP1); //this work Oktemp = CWnd::Create (NULL,_T(""),WS_CHILD|WS_CLIPCHILDREN, rect, pParentWnd, nID ,pContext); //this work, I can see the button and catch his command Oktemp &= m_cBouton_1.Create (_T(""),WS_CHILD |BS_PUSHBUTTON|BS_BITMAP|WS_VISIBLE ,CRect(0,0,100,100),this,IDC_BUTTONGAUCHE); //and the bitmap is never displayed on the button.... //do I have to set a different Style ti my button? m_cBouton_1.SetBitmap(MyBitmap); m_cBouton_1.ShowWindow(SW_SHOWNORMAL); return Oktemp; } Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        The MyBitmap goes out of scope, so the bitmap is destroyed. Make the object a member variable so it stays around for the life of the control. --Mike-- http://home.inreach.com/mdunn/ A recent survey reports that 1/4 of all internet users in England surf for porn. The other 3/4 just didn't want to admit it.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups