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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Static controls

Static controls

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

    I'm trying to display a bitmap in a Dialog and I've created a static control named IDC_PICTURE. I added this through the resource editor and placed it in my dialog and associated a picture. The picture shows up fine when i run my program. What i want to do is change the picture during the program to a different bitmap. I added the second bitmap to the resource list (right under the first one) and I'm trying to figure out how I can get control over which bitmap is displayed. Usually, I work with simple edit boxes and I do the following to gain control over them. CWnd * pWnd = GetDlgItem(IDC_BYTE0);//where IDC_BYTE0 is an edit control pWnd->ShowWindow(SW_SHOW); // i use this to control it, in this case to make it show instead of hidden. I want to do this: CStatic *pPic = GetDlgItem(IDC_PICTURE);//where IDC_PICTURE is the static control of type picture so i can do this pPic->SetBitmap(IDB_BITMAP2) //where IDB_BITMAP is the first one and IDB_BITMAP2 is the second picture This code doesn't compile because GetDlgItem returns a CWnd type pointer.. but how do i get the pointer I need to use the CStatic functions? Thanks Jeff Rothenberg Project Engineer Vector CANtech, Inc.

    D P 2 Replies Last reply
    0
    • E electronicman_x

      I'm trying to display a bitmap in a Dialog and I've created a static control named IDC_PICTURE. I added this through the resource editor and placed it in my dialog and associated a picture. The picture shows up fine when i run my program. What i want to do is change the picture during the program to a different bitmap. I added the second bitmap to the resource list (right under the first one) and I'm trying to figure out how I can get control over which bitmap is displayed. Usually, I work with simple edit boxes and I do the following to gain control over them. CWnd * pWnd = GetDlgItem(IDC_BYTE0);//where IDC_BYTE0 is an edit control pWnd->ShowWindow(SW_SHOW); // i use this to control it, in this case to make it show instead of hidden. I want to do this: CStatic *pPic = GetDlgItem(IDC_PICTURE);//where IDC_PICTURE is the static control of type picture so i can do this pPic->SetBitmap(IDB_BITMAP2) //where IDB_BITMAP is the first one and IDB_BITMAP2 is the second picture This code doesn't compile because GetDlgItem returns a CWnd type pointer.. but how do i get the pointer I need to use the CStatic functions? Thanks Jeff Rothenberg Project Engineer Vector CANtech, Inc.

      D Offline
      D Offline
      dabs
      wrote on last edited by
      #2

      CStatic* pWnd = static_cast< CStatic* >( GetDlgItem( IDC_BYTE0 ) );


      Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

      1 Reply Last reply
      0
      • E electronicman_x

        I'm trying to display a bitmap in a Dialog and I've created a static control named IDC_PICTURE. I added this through the resource editor and placed it in my dialog and associated a picture. The picture shows up fine when i run my program. What i want to do is change the picture during the program to a different bitmap. I added the second bitmap to the resource list (right under the first one) and I'm trying to figure out how I can get control over which bitmap is displayed. Usually, I work with simple edit boxes and I do the following to gain control over them. CWnd * pWnd = GetDlgItem(IDC_BYTE0);//where IDC_BYTE0 is an edit control pWnd->ShowWindow(SW_SHOW); // i use this to control it, in this case to make it show instead of hidden. I want to do this: CStatic *pPic = GetDlgItem(IDC_PICTURE);//where IDC_PICTURE is the static control of type picture so i can do this pPic->SetBitmap(IDB_BITMAP2) //where IDB_BITMAP is the first one and IDB_BITMAP2 is the second picture This code doesn't compile because GetDlgItem returns a CWnd type pointer.. but how do i get the pointer I need to use the CStatic functions? Thanks Jeff Rothenberg Project Engineer Vector CANtech, Inc.

        P Offline
        P Offline
        Philip Patrick
        wrote on last edited by
        #3

        Just cast it to CStatic:

        CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE);

        Philip Patrick Web-site: www.stpworks.com "Two beer or not two beer?" Shakesbeer

        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