Painting Several Images - not refreshing screen
-
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
-
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
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/[^]
-
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
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.
-
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/[^]