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. [Win32]Set bitmap to button

[Win32]Set bitmap to button

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
10 Posts 4 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.
  • M Offline
    M Offline
    Member 2965471
    wrote on last edited by
    #1

    Hi, I want to add a bitmap to a button in my DialogBox. The code is:

    case WM_INITDIALOG:

    hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_QUIT));
    SendMessage(GetDlgItem(hDlg,ID_QUIT),BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBmp);

    return (INT_PTR)TRUE;

    but why don't work?

    C A 2 Replies Last reply
    0
    • M Member 2965471

      Hi, I want to add a bitmap to a button in my DialogBox. The code is:

      case WM_INITDIALOG:

      hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_QUIT));
      SendMessage(GetDlgItem(hDlg,ID_QUIT),BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBmp);

      return (INT_PTR)TRUE;

      but why don't work?

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      if it was that easy, CP wouldn't need four dozen articles on bitmap buttons[^]

      image processing toolkits | batch image processing

      M 1 Reply Last reply
      0
      • C Chris Losinger

        if it was that easy, CP wouldn't need four dozen articles on bitmap buttons[^]

        image processing toolkits | batch image processing

        M Offline
        M Offline
        Member 2965471
        wrote on last edited by
        #3

        but is it possible to add an image with BM_SETIMAGE without ownerdraw button?

        C 1 Reply Last reply
        0
        • M Member 2965471

          Hi, I want to add a bitmap to a button in my DialogBox. The code is:

          case WM_INITDIALOG:

          hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_QUIT));
          SendMessage(GetDlgItem(hDlg,ID_QUIT),BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBmp);

          return (INT_PTR)TRUE;

          but why don't work?

          A Offline
          A Offline
          Abhi Lahare
          wrote on last edited by
          #4

          What is the return value of LoadBitmap function?

          M 1 Reply Last reply
          0
          • M Member 2965471

            but is it possible to add an image with BM_SETIMAGE without ownerdraw button?

            C Offline
            C Offline
            Chris Losinger
            wrote on last edited by
            #5

            are you setting the BS_BITMAP style when you create the button?

            image processing toolkits | batch image processing

            M 1 Reply Last reply
            0
            • A Abhi Lahare

              What is the return value of LoadBitmap function?

              M Offline
              M Offline
              Member 2965471
              wrote on last edited by
              #6

              not NULL

              1 Reply Last reply
              0
              • C Chris Losinger

                are you setting the BS_BITMAP style when you create the button?

                image processing toolkits | batch image processing

                M Offline
                M Offline
                Member 2965471
                wrote on last edited by
                #7

                no because with BS_BITMAP style show bitmap only without text in the button. I need [Bitmap+Text]

                L 1 Reply Last reply
                0
                • M Member 2965471

                  no because with BS_BITMAP style show bitmap only without text in the button. I need [Bitmap+Text]

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

                  Member 2965471 wrote:

                  I need [Bitmap+Text]

                  See here[^] for more details.

                  The best things in life are not things.

                  M 1 Reply Last reply
                  0
                  • L Lost User

                    Member 2965471 wrote:

                    I need [Bitmap+Text]

                    See here[^] for more details.

                    The best things in life are not things.

                    M Offline
                    M Offline
                    Member 2965471
                    wrote on last edited by
                    #9

                    I know but don't work in that way!

                    L 1 Reply Last reply
                    0
                    • M Member 2965471

                      I know but don't work in that way!

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

                      Member 2965471 wrote:

                      I know but don't work in that way!

                      I have just tested this and it works OK. You need to ensure that your bitmap is the same size or smaller than your button. Also if you need to show both bitmap and text, then you must ensure that your bitmap is small enough to leave space for the text.

                      The best things in life are not things.

                      modified on Thursday, June 16, 2011 9:35 AM

                      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