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. Dialog background picture

Dialog background picture

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
3 Posts 2 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.
  • A Offline
    A Offline
    aarontan
    wrote on last edited by
    #1

    Hi, I have used the following codes to load a bitmap onto the dialog box for the background during onPaint.However I need to change the picture when i click another button. Is there a function which i can call to redraw the bitmap again? cos when i put these code into a function, it doesnt work. Any idea? [code] CDC BmpDc; CPaintDC dc(this); VERIFY( BmpDc.CreateCompatibleDC(&dc) ); CBitmap BkBmp, *pOldBmp; //BkBmp. BkBmp.LoadBitmap(IDB_background); pOldBmp = (CBitmap *)BmpDc.SelectObject(&BkBmp); dc.BitBlt(0,0,m_nW,m_nH,&BmpDc,0,0,SRCCOPY); BmpDc.SelectObject(pOldBmp); [/code] :confused: Newb VCer

    J 1 Reply Last reply
    0
    • A aarontan

      Hi, I have used the following codes to load a bitmap onto the dialog box for the background during onPaint.However I need to change the picture when i click another button. Is there a function which i can call to redraw the bitmap again? cos when i put these code into a function, it doesnt work. Any idea? [code] CDC BmpDc; CPaintDC dc(this); VERIFY( BmpDc.CreateCompatibleDC(&dc) ); CBitmap BkBmp, *pOldBmp; //BkBmp. BkBmp.LoadBitmap(IDB_background); pOldBmp = (CBitmap *)BmpDc.SelectObject(&BkBmp); dc.BitBlt(0,0,m_nW,m_nH,&BmpDc,0,0,SRCCOPY); BmpDc.SelectObject(pOldBmp); [/code] :confused: Newb VCer

      J Offline
      J Offline
      Jose Lamas Rios
      wrote on last edited by
      #2

      If OnPaint() takes the bitmap ID from a member variable and paints it, your button handler might simply change the ID of the bitmap to draw and invalidate the window. Something like this: // Set the new background m_BackBitmapID = IDB_Background1; // Just invalidate the window // OnPaint will do the job. Invalidate(); -- jlr http://jlamas.blogspot.com/[^]

      A 1 Reply Last reply
      0
      • J Jose Lamas Rios

        If OnPaint() takes the bitmap ID from a member variable and paints it, your button handler might simply change the ID of the bitmap to draw and invalidate the window. Something like this: // Set the new background m_BackBitmapID = IDB_Background1; // Just invalidate the window // OnPaint will do the job. Invalidate(); -- jlr http://jlamas.blogspot.com/[^]

        A Offline
        A Offline
        aarontan
        wrote on last edited by
        #3

        Tks man it works.

        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