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. how come my bmp is not displayed? thank you

how come my bmp is not displayed? thank you

Scheduled Pinned Locked Moved C / C++ / MFC
learningc++question
6 Posts 5 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.
  • E Offline
    E Offline
    ewighell
    wrote on last edited by
    #1

    First, I create a bmp control on a Dialog, and set its ID to ID_MYBMP second, I creat a member variable for the bmp control as m_mybmp; third, I import a bmp file into the resource and name it IDB_MYBMP; forth, I add following code to the funcion OnInitDialog()

    BOOL CMyDlg::OnInitDialog()
    {
    CDialog::OnInitDialog();

    CBitmap bmp;
    bmp.LoadBitmap(IDB\_MYBMP);
    m\_mybmp.SetBitmap((HBITMAP)bmp);
    

    }

    Thank you very much!!! ------------------- I am learning C++ and English

    C L H PJ ArendsP E 5 Replies Last reply
    0
    • E ewighell

      First, I create a bmp control on a Dialog, and set its ID to ID_MYBMP second, I creat a member variable for the bmp control as m_mybmp; third, I import a bmp file into the resource and name it IDB_MYBMP; forth, I add following code to the funcion OnInitDialog()

      BOOL CMyDlg::OnInitDialog()
      {
      CDialog::OnInitDialog();

      CBitmap bmp;
      bmp.LoadBitmap(IDB\_MYBMP);
      m\_mybmp.SetBitmap((HBITMAP)bmp);
      

      }

      Thank you very much!!! ------------------- I am learning C++ and English

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I'd check if bmp contains a bitmap, in the debugger. One way is just to call GetWidth and see what you get back. Then you can focus on the bitmap control as a possible source of the problem. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • E ewighell

        First, I create a bmp control on a Dialog, and set its ID to ID_MYBMP second, I creat a member variable for the bmp control as m_mybmp; third, I import a bmp file into the resource and name it IDB_MYBMP; forth, I add following code to the funcion OnInitDialog()

        BOOL CMyDlg::OnInitDialog()
        {
        CDialog::OnInitDialog();

        CBitmap bmp;
        bmp.LoadBitmap(IDB\_MYBMP);
        m\_mybmp.SetBitmap((HBITMAP)bmp);
        

        }

        Thank you very much!!! ------------------- I am learning C++ and English

        L Offline
        L Offline
        Laxman Auti
        wrote on last edited by
        #3

        Try the following code as it works in my application for same

        CBitmap bmp;
        bmp.LoadBitmap(MAKEINTRESOURCE(IDB_SCHEDULE));
        m_Schedule.SetBitmap(bmp);
        bmp.Detach();

        Hope it works for you Knock out "T" from CAN'T You 'CAN' if you think you 'CAN' :cool: -- modified at 0:13 Wednesday 12th April, 2006

        1 Reply Last reply
        0
        • E ewighell

          First, I create a bmp control on a Dialog, and set its ID to ID_MYBMP second, I creat a member variable for the bmp control as m_mybmp; third, I import a bmp file into the resource and name it IDB_MYBMP; forth, I add following code to the funcion OnInitDialog()

          BOOL CMyDlg::OnInitDialog()
          {
          CDialog::OnInitDialog();

          CBitmap bmp;
          bmp.LoadBitmap(IDB\_MYBMP);
          m\_mybmp.SetBitmap((HBITMAP)bmp);
          

          }

          Thank you very much!!! ------------------- I am learning C++ and English

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Hi ewighell Do you set Bitmap(false) to true in property window from control?

          1 Reply Last reply
          0
          • E ewighell

            First, I create a bmp control on a Dialog, and set its ID to ID_MYBMP second, I creat a member variable for the bmp control as m_mybmp; third, I import a bmp file into the resource and name it IDB_MYBMP; forth, I add following code to the funcion OnInitDialog()

            BOOL CMyDlg::OnInitDialog()
            {
            CDialog::OnInitDialog();

            CBitmap bmp;
            bmp.LoadBitmap(IDB\_MYBMP);
            m\_mybmp.SetBitmap((HBITMAP)bmp);
            

            }

            Thank you very much!!! ------------------- I am learning C++ and English

            PJ ArendsP Offline
            PJ ArendsP Offline
            PJ Arends
            wrote on last edited by
            #5

            The bitmap is destroyed when your CBitmap object goes out of scope. Make the CBitmap a member of your dialog class.


            You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

            Within you lies the power for good; Use it!

            1 Reply Last reply
            0
            • E ewighell

              First, I create a bmp control on a Dialog, and set its ID to ID_MYBMP second, I creat a member variable for the bmp control as m_mybmp; third, I import a bmp file into the resource and name it IDB_MYBMP; forth, I add following code to the funcion OnInitDialog()

              BOOL CMyDlg::OnInitDialog()
              {
              CDialog::OnInitDialog();

              CBitmap bmp;
              bmp.LoadBitmap(IDB\_MYBMP);
              m\_mybmp.SetBitmap((HBITMAP)bmp);
              

              }

              Thank you very much!!! ------------------- I am learning C++ and English

              E Offline
              E Offline
              ewighell
              wrote on last edited by
              #6

              I made it with your helps. Thank you all very much!!! ------------------- I am learning C++ and English

              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