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 to .place a Image (BMP, JPEG etc) on a Button

How to .place a Image (BMP, JPEG etc) on a Button

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
6 Posts 5 Posters 1 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.
  • Z Offline
    Z Offline
    Zeeshan Bilal
    wrote on last edited by
    #1

    HI How to place a Image (BMP, JPEG etc) on a Button. TO make my interface .. Good Looking. Plz tell me.. or sample code thanx

    H D N 3 Replies Last reply
    0
    • Z Zeeshan Bilal

      HI How to place a Image (BMP, JPEG etc) on a Button. TO make my interface .. Good Looking. Plz tell me.. or sample code thanx

      H Offline
      H Offline
      HENDRIK R
      wrote on last edited by
      #2

      Zeeshan Bilal wrote: How to place a Image (BMP, JPEG etc) on a Button Either create a CButton object using the BS_BITMAP style, or derive your own class from CButton and do the drawing yourself. The latter solution could for example make use of the IPicture interface to actually display the image.


      We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve

      G 1 Reply Last reply
      0
      • H HENDRIK R

        Zeeshan Bilal wrote: How to place a Image (BMP, JPEG etc) on a Button Either create a CButton object using the BS_BITMAP style, or derive your own class from CButton and do the drawing yourself. The latter solution could for example make use of the IPicture interface to actually display the image.


        We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve

        G Offline
        G Offline
        gamitech
        wrote on last edited by
        #3

        but how can you do it in a win32 api if you have a dialog box as a resource. is there another way of doing it without having a class. with loading a bitmap and then placing it ? gabby

        H 1 Reply Last reply
        0
        • G gamitech

          but how can you do it in a win32 api if you have a dialog box as a resource. is there another way of doing it without having a class. with loading a bitmap and then placing it ? gabby

          H Offline
          H Offline
          HENDRIK R
          wrote on last edited by
          #4

          As you surely know you create a button using CreateWindow, specifying BUTTON as class name. Also here you can specify BS_BITMAP as a window style, and then use BM_SETIMAGE to place an image on the button.


          We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve

          1 Reply Last reply
          0
          • Z Zeeshan Bilal

            HI How to place a Image (BMP, JPEG etc) on a Button. TO make my interface .. Good Looking. Plz tell me.. or sample code thanx

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

            Have you seen this class?


            "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

            1 Reply Last reply
            0
            • Z Zeeshan Bilal

              HI How to place a Image (BMP, JPEG etc) on a Button. TO make my interface .. Good Looking. Plz tell me.. or sample code thanx

              N Offline
              N Offline
              normanS
              wrote on last edited by
              #6

              I found that using an Icon on a button worked better than a bitmap (but the process is very similar.) I used the examples in the MSDN library (VC6 version) The SDK-level code I used is something like this: hwndMyButton = CreateWindow("button", "", WS_CHILD | WS_VISIBLE | BS_ICON | BS_PUSHBUTTON, buttonPosX, buttonPosY, ButtonWidth, ButtonHeight, hwnd, (HMENU)ID_ButtonID, hAppInst, NULL); hButtonIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_ButtonIcon)); SendMessage(hwndMyButton, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)(HANDLE)hButtonIcon); I later changed to using a toolbar, because that looks more modern than Icons or Bitmaps on buttons!

              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