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 load bitmap on picture ctrl

how to load bitmap on picture ctrl

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelptutorial
11 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.
  • B baldha rakesh

    i am trying like this but this give reference error please reply ASAP CBitmap *bitmap1=(CBitmap *)GetDlgItem(IDC_STATIC1); bitmap1->LoadBitmap(IDB_BITMAP1); Bankey Khandelwal Software Engineer

    N Offline
    N Offline
    Nibu babu thomas
    wrote on last edited by
    #2

    Bankey Khandelwal wrote:

    CBitmap *bitmap1=(CBitmap *)GetDlgItem(IDC_STATIC1); bitmap1->LoadBitmap(IDB_BITMAP1);

    GetDlgItem(...) returns a CWnd*. You are trying to cast it to a bitmap. This is wrong. You should do it like this...

    CBitmap bmp;
    bmp.LoadBitmap(IDB_BITMAP1);
    CStatic *pStatic = (CStatic*)GetDlgItem(IDC_STATIC1);
    pStatic->SetBitmap(bmp);


    Nibu thomas Software Developer

    B 1 Reply Last reply
    0
    • B baldha rakesh

      i am trying like this but this give reference error please reply ASAP CBitmap *bitmap1=(CBitmap *)GetDlgItem(IDC_STATIC1); bitmap1->LoadBitmap(IDB_BITMAP1); Bankey Khandelwal Software Engineer

      J Offline
      J Offline
      janisha
      wrote on last edited by
      #3

      U can directly load on picture control by changing the control properties Right click on picture control and change type to bitmap and select bitmap id in Image. :cool:

      1 Reply Last reply
      0
      • N Nibu babu thomas

        Bankey Khandelwal wrote:

        CBitmap *bitmap1=(CBitmap *)GetDlgItem(IDC_STATIC1); bitmap1->LoadBitmap(IDB_BITMAP1);

        GetDlgItem(...) returns a CWnd*. You are trying to cast it to a bitmap. This is wrong. You should do it like this...

        CBitmap bmp;
        bmp.LoadBitmap(IDB_BITMAP1);
        CStatic *pStatic = (CStatic*)GetDlgItem(IDC_STATIC1);
        pStatic->SetBitmap(bmp);


        Nibu thomas Software Developer

        B Offline
        B Offline
        baldha rakesh
        wrote on last edited by
        #4

        thanks you, it is loading but not show on button where is i wrong please reply Bankey Khandelwal Software Engineer

        N S 2 Replies Last reply
        0
        • B baldha rakesh

          thanks you, it is loading but not show on button where is i wrong please reply Bankey Khandelwal Software Engineer

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #5

          Bankey Khandelwal wrote:

          not show on button

          Is it a button! or Is it a Static!


          Nibu thomas Software Developer

          B 1 Reply Last reply
          0
          • B baldha rakesh

            i am trying like this but this give reference error please reply ASAP CBitmap *bitmap1=(CBitmap *)GetDlgItem(IDC_STATIC1); bitmap1->LoadBitmap(IDB_BITMAP1); Bankey Khandelwal Software Engineer

            _ Offline
            _ Offline
            _AnsHUMAN_
            wrote on last edited by
            #6

            Set the type of button as bitmap and perform the following : (here m_bit is an object of CBitmap , m_btnStart is the variable for CBitmapButton) m_bit1.LoadBitmap(IDB_BMPSTART); HBITMAP hBit1 = (HBITMAP) m_bit1.GetSafeHandle(); m_btnStart.SetBitmap(hBit1); // Use m_btnStart.SizeToContent() if you want to set the size of the button to that of the image being displayed on it (open the resource editor and copy the .gif image to the bitmap image in the resource editor) *******and yes on the picture control you have to set the type as bitmap and pass the image name of the bitmap in the IMAGE option of resource editor Vision is Always important and so is your ATTITUDE. Wishes. Anshuman Dandekar -- modified at 5:31 Thursday 2nd March, 2006

            1 Reply Last reply
            0
            • N Nibu babu thomas

              Bankey Khandelwal wrote:

              not show on button

              Is it a button! or Is it a Static!


              Nibu thomas Software Developer

              B Offline
              B Offline
              baldha rakesh
              wrote on last edited by
              #7

              it is static Bankey Khandelwal Software Engineer

              N 1 Reply Last reply
              0
              • B baldha rakesh

                it is static Bankey Khandelwal Software Engineer

                N Offline
                N Offline
                Nibu babu thomas
                wrote on last edited by
                #8

                Your static control must have the style SS_BITMAP(for bitmap) or SS_ICON(for icon).


                Nibu thomas Software Developer

                B 1 Reply Last reply
                0
                • N Nibu babu thomas

                  Your static control must have the style SS_BITMAP(for bitmap) or SS_ICON(for icon).


                  Nibu thomas Software Developer

                  B Offline
                  B Offline
                  baldha rakesh
                  wrote on last edited by
                  #9

                  ya there is type bitmap but there is no style property like bitmap etc. Bankey Khandelwal Software Engineer

                  N 1 Reply Last reply
                  0
                  • B baldha rakesh

                    ya there is type bitmap but there is no style property like bitmap etc. Bankey Khandelwal Software Engineer

                    N Offline
                    N Offline
                    Nibu babu thomas
                    wrote on last edited by
                    #10

                    Bankey Khandelwal wrote:

                    ya there is type bitmap

                    Yes that is the one.


                    Nibu thomas Software Developer

                    1 Reply Last reply
                    0
                    • B baldha rakesh

                      thanks you, it is loading but not show on button where is i wrong please reply Bankey Khandelwal Software Engineer

                      S Offline
                      S Offline
                      sunithakiranmaye
                      wrote on last edited by
                      #11

                      You said it is loading but not show on button,the reason is u have to check the button properites as ownerdraw. It works now Kiranmaye

                      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