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. MFC Picture Control image size.

MFC Picture Control image size.

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsdesignhelpquestion
7 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.
  • M Offline
    M Offline
    Maximilien
    wrote on last edited by
    #1

    (google-fu seems to be lacking today, and I'm certain I'm not asking or doing the right thing) I have defined a UI in the resource editor with a Picture Control and assign a bitmap on it :

    CONTROL IDB\_BITMAP1,IDC\_BACKGROUND\_PICTURE,"Static",SS\_BITMAP | SS\_CENTERIMAGE,14,7,425,263
    

    The problem is that sometimes (most of the time) the actual bitmap does not have the same size as the picture control. Is there a way to know the actual pixel size of the Picture Control ? Am I doing this the wrong way? or Am I forced to do this in code (get picturecontrol client size, and StretchBlt ... )? Thanks.

    I'd rather be phishing!

    V L 2 Replies Last reply
    0
    • M Maximilien

      (google-fu seems to be lacking today, and I'm certain I'm not asking or doing the right thing) I have defined a UI in the resource editor with a Picture Control and assign a bitmap on it :

      CONTROL IDB\_BITMAP1,IDC\_BACKGROUND\_PICTURE,"Static",SS\_BITMAP | SS\_CENTERIMAGE,14,7,425,263
      

      The problem is that sometimes (most of the time) the actual bitmap does not have the same size as the picture control. Is there a way to know the actual pixel size of the Picture Control ? Am I doing this the wrong way? or Am I forced to do this in code (get picturecontrol client size, and StretchBlt ... )? Thanks.

      I'd rather be phishing!

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      Maximilien wrote:

      Is there a way to know the actual pixel size of the Picture Control ?

      You already set this size in the .rc file. But if you mean the real image size... Well, first try to "play" with SS_REALSIZEIMAGE and SS_CENTERIMAGE flags. If it won't help then try to owner-draw. //edit: you could use [GetBitmapDimensionEx function (wingdi.h) | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbitmapdimensionex) to obtain bitmap size.

      M 1 Reply Last reply
      0
      • M Maximilien

        (google-fu seems to be lacking today, and I'm certain I'm not asking or doing the right thing) I have defined a UI in the resource editor with a Picture Control and assign a bitmap on it :

        CONTROL IDB\_BITMAP1,IDC\_BACKGROUND\_PICTURE,"Static",SS\_BITMAP | SS\_CENTERIMAGE,14,7,425,263
        

        The problem is that sometimes (most of the time) the actual bitmap does not have the same size as the picture control. Is there a way to know the actual pixel size of the Picture Control ? Am I doing this the wrong way? or Am I forced to do this in code (get picturecontrol client size, and StretchBlt ... )? Thanks.

        I'd rather be phishing!

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

        You know the size of the picture control from the resource file. Or you can use GetWindowRect or GetClientRect to capture it at run time. You can then use StretchBlt[^] to display the bitmap at the appropriate size. Alternatively, depending on what else is in your view, you could resize the picture control.

        M 1 Reply Last reply
        0
        • V Victor Nijegorodov

          Maximilien wrote:

          Is there a way to know the actual pixel size of the Picture Control ?

          You already set this size in the .rc file. But if you mean the real image size... Well, first try to "play" with SS_REALSIZEIMAGE and SS_CENTERIMAGE flags. If it won't help then try to owner-draw. //edit: you could use [GetBitmapDimensionEx function (wingdi.h) | Microsoft Docs](https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbitmapdimensionex) to obtain bitmap size.

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          thanks. will skip MFC and do it the good old way.

          I'd rather be phishing!

          V 1 Reply Last reply
          0
          • L Lost User

            You know the size of the picture control from the resource file. Or you can use GetWindowRect or GetClientRect to capture it at run time. You can then use StretchBlt[^] to display the bitmap at the appropriate size. Alternatively, depending on what else is in your view, you could resize the picture control.

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            thanks. will skip MFC and do it the good old way.

            I'd rather be phishing!

            L 1 Reply Last reply
            0
            • M Maximilien

              thanks. will skip MFC and do it the good old way.

              I'd rather be phishing!

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

              You can still do some of that in MFC.

              1 Reply Last reply
              0
              • M Maximilien

                thanks. will skip MFC and do it the good old way.

                I'd rather be phishing!

                V Offline
                V Offline
                Victor Nijegorodov
                wrote on last edited by
                #7

                Your problem has nothing to do with MFC! MFC is just a wrapper for plain Win32 API

                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