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. Painting Several Images - not refreshing screen

Painting Several Images - not refreshing screen

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

    Hello, Im using the following line of code to draw a image in a window: hSkinBmp=(HBITMAP)LoadImage(NULL, name, IMAGE_BITMAP, 0,0,LR_LOADFROMFILE); HDC hdc = BeginPaint(hWnd6, &ps); HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hSkinBmp); GetObject(hSkinBmp, sizeof(bm), &bm); BitBlt(hdc, 2, 30, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); ReleaseDC(hWnd6,hdc); EndPaint(hWnd6, &ps); UpdateWindow(hWnd6); -- And it works, the image is being drawn on the window, but then when try to run this function again to load a different image in the same window (like a slideshow), the second image is not shown on the window (the old image stays), untill I minimize and maximize the window. What could be the reason for that? Thx in advance

    J B 2 Replies Last reply
    0
    • S seq

      Hello, Im using the following line of code to draw a image in a window: hSkinBmp=(HBITMAP)LoadImage(NULL, name, IMAGE_BITMAP, 0,0,LR_LOADFROMFILE); HDC hdc = BeginPaint(hWnd6, &ps); HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hSkinBmp); GetObject(hSkinBmp, sizeof(bm), &bm); BitBlt(hdc, 2, 30, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); ReleaseDC(hWnd6,hdc); EndPaint(hWnd6, &ps); UpdateWindow(hWnd6); -- And it works, the image is being drawn on the window, but then when try to run this function again to load a different image in the same window (like a slideshow), the second image is not shown on the window (the old image stays), untill I minimize and maximize the window. What could be the reason for that? Thx in advance

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

      grep2 wrote: And it works, the image is being drawn on the window, but then when try to run this function again to load a different image in the same window (like a slideshow), the second image is not shown on the window (the old image stays), untill I minimize and maximize the window. I'm not sure if that's the problem, but I'd try invalidating the window before drawing the second image. -- jlr http://jlamas.blogspot.com/[^]

      S 1 Reply Last reply
      0
      • S seq

        Hello, Im using the following line of code to draw a image in a window: hSkinBmp=(HBITMAP)LoadImage(NULL, name, IMAGE_BITMAP, 0,0,LR_LOADFROMFILE); HDC hdc = BeginPaint(hWnd6, &ps); HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hSkinBmp); GetObject(hSkinBmp, sizeof(bm), &bm); BitBlt(hdc, 2, 30, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); ReleaseDC(hWnd6,hdc); EndPaint(hWnd6, &ps); UpdateWindow(hWnd6); -- And it works, the image is being drawn on the window, but then when try to run this function again to load a different image in the same window (like a slideshow), the second image is not shown on the window (the old image stays), untill I minimize and maximize the window. What could be the reason for that? Thx in advance

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        Is this by any chance in an OnDraw handler? If so, then you should not have the UpdateWindow() at the end of the function. If not, then the BeginPaint and EndPaint are not the proper mechanism for getting your DC, you should use GetDC and ReleaseDC instead. BeginPaint and EndPaint are ONLY for use in the WM_PAINT or OnDraw handlers. This is most certainly a fundamental part of your problem.

        1 Reply Last reply
        0
        • J Jose Lamas Rios

          grep2 wrote: And it works, the image is being drawn on the window, but then when try to run this function again to load a different image in the same window (like a slideshow), the second image is not shown on the window (the old image stays), untill I minimize and maximize the window. I'm not sure if that's the problem, but I'd try invalidating the window before drawing the second image. -- jlr http://jlamas.blogspot.com/[^]

          S Offline
          S Offline
          seq
          wrote on last edited by
          #4

          Thank you both for taking you time to answer my question, but infact the first answer solved my problem, invalidating the window area worked fine.

          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