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. Picture control question

Picture control question

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • B Offline
    B Offline
    ben2
    wrote on last edited by
    #1

    -------------------------------------------------------------------------------- Hi, I want to change the BMP from the picture control once I press a button. It seemed like I have to press twice on the button to change first time and then it never changes. Here is the code: BOOL CSdsdDlg::OnInitDialog() { CDialog::OnInitDialog(); HBITMAP hBmp1 = (HBITMAP ) ::LoadImage(NULL, _T("c:\\1.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_pic.SetBitmap(hBmp1); ............... } void CSdsdDlg::OnButton1() { HBITMAP hBmp2 = (HBITMAP ) ::LoadImage(NULL, _T("c:\\cool.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (m_pic.GetBitmap()== hBmp1) m_pic.SetBitmap(hBmp2); else m_pic.SetBitmap(hBmp1); return; }

    O R 2 Replies Last reply
    0
    • B ben2

      -------------------------------------------------------------------------------- Hi, I want to change the BMP from the picture control once I press a button. It seemed like I have to press twice on the button to change first time and then it never changes. Here is the code: BOOL CSdsdDlg::OnInitDialog() { CDialog::OnInitDialog(); HBITMAP hBmp1 = (HBITMAP ) ::LoadImage(NULL, _T("c:\\1.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_pic.SetBitmap(hBmp1); ............... } void CSdsdDlg::OnButton1() { HBITMAP hBmp2 = (HBITMAP ) ::LoadImage(NULL, _T("c:\\cool.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (m_pic.GetBitmap()== hBmp1) m_pic.SetBitmap(hBmp2); else m_pic.SetBitmap(hBmp1); return; }

      O Offline
      O Offline
      oustar
      wrote on last edited by
      #2

      What is the return values of "m_pic.GetBitmap()"? Perhaps the problem is in "m_pic.SetBitmap(XXX). You don't set the correct flag.

      1 Reply Last reply
      0
      • B ben2

        -------------------------------------------------------------------------------- Hi, I want to change the BMP from the picture control once I press a button. It seemed like I have to press twice on the button to change first time and then it never changes. Here is the code: BOOL CSdsdDlg::OnInitDialog() { CDialog::OnInitDialog(); HBITMAP hBmp1 = (HBITMAP ) ::LoadImage(NULL, _T("c:\\1.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_pic.SetBitmap(hBmp1); ............... } void CSdsdDlg::OnButton1() { HBITMAP hBmp2 = (HBITMAP ) ::LoadImage(NULL, _T("c:\\cool.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (m_pic.GetBitmap()== hBmp1) m_pic.SetBitmap(hBmp2); else m_pic.SetBitmap(hBmp1); return; }

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        You're better off keeping a class member variable specifying which bitmap is currently displayed, as GetBitmap() may not necessarily return the same handle that you give it, although it probably will. Also, you're comparing against hBmp1 in OnButton1(), but in OnInitDialog(), hBmp1 is a local variable. There must be another definition somewhere that is causing the code to work unexpectedly.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        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