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. adding bitmap to a cbutton

adding bitmap to a cbutton

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestionlearning
6 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.
  • P Offline
    P Offline
    prateekkathuria
    wrote on last edited by
    #1

    I am trying to add a bit map to a cbutton. In the resource editor i do set the bitmap property to true. On the init dialog this is what i have. CButton* pButton = (CButton*) GetDlgItem(BUTTON_ID); CBitmap bmp; bmp.LoadBitmap(BITMAP_ID); HBITMAP hBmp = HBITMAP(bmp); pButton->SetBitmap(hBmp); the bitmap doesnt appear any suggestions? What am i doing wrong??? Thanks in advance

    D P RaviBeeR 3 Replies Last reply
    0
    • P prateekkathuria

      I am trying to add a bit map to a cbutton. In the resource editor i do set the bitmap property to true. On the init dialog this is what i have. CButton* pButton = (CButton*) GetDlgItem(BUTTON_ID); CBitmap bmp; bmp.LoadBitmap(BITMAP_ID); HBITMAP hBmp = HBITMAP(bmp); pButton->SetBitmap(hBmp); the bitmap doesnt appear any suggestions? What am i doing wrong??? Thanks in advance

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Try this one.


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      1 Reply Last reply
      0
      • P prateekkathuria

        I am trying to add a bit map to a cbutton. In the resource editor i do set the bitmap property to true. On the init dialog this is what i have. CButton* pButton = (CButton*) GetDlgItem(BUTTON_ID); CBitmap bmp; bmp.LoadBitmap(BITMAP_ID); HBITMAP hBmp = HBITMAP(bmp); pButton->SetBitmap(hBmp); the bitmap doesnt appear any suggestions? What am i doing wrong??? Thanks in advance

        P Offline
        P Offline
        prateekkathuria
        wrote on last edited by
        #3

        thats a subclass and thats what i dont wanna do. I also tried adding the style BS_BITMAP thru the setwindowlong just to makesure the style was being set but no luck.....

        1 Reply Last reply
        0
        • P prateekkathuria

          I am trying to add a bit map to a cbutton. In the resource editor i do set the bitmap property to true. On the init dialog this is what i have. CButton* pButton = (CButton*) GetDlgItem(BUTTON_ID); CBitmap bmp; bmp.LoadBitmap(BITMAP_ID); HBITMAP hBmp = HBITMAP(bmp); pButton->SetBitmap(hBmp); the bitmap doesnt appear any suggestions? What am i doing wrong??? Thanks in advance

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          Perhaps bmp is going out of scope and thereby causing badness? Also see my article, FooButton[^]. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          P 1 Reply Last reply
          0
          • RaviBeeR RaviBee

            Perhaps bmp is going out of scope and thereby causing badness? Also see my article, FooButton[^]. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

            P Offline
            P Offline
            prateekkathuria
            wrote on last edited by
            #5

            setbitmap takes an object so i dont think that could be a reason. But may be its worth trying.

            P 1 Reply Last reply
            0
            • P prateekkathuria

              setbitmap takes an object so i dont think that could be a reason. But may be its worth trying.

              P Offline
              P Offline
              prateekkathuria
              wrote on last edited by
              #6

              sorry ravi, it was a scoping issue but i am still not clear why. the CBitmap bmp; is required to be a class level member. I was assuming that when we call a setbitmap on the button and pass a HBITMAP to it, a copy should be sent and there should be no scoping issue.

              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