How to redraw the desktop screen
Hello everyone, I'm trying to redraw the screen after printing something on the screen, here is my code :
The comments is the missing code that I need
Code:
#include <windows.h>
#include <tchar.h>
#include <iostream>
int main()
{
HDC hdc = CreateCompatibleDC(NULL);
HBITMAP hbitmap = (HBITMAP)LoadImage(NULL,_T("C:\\Printer.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
while (1)
{
// Save the screen before printing
SelectObject(hdc, hbitmap);
HDC hdc_x = GetDC(HWND_DESKTOP);
BitBlt(hdc_x, 488, 359, 300, 300, hdc, 0, 0, SRCCOPY);
ReleaseDC(HWND_DESKTOP, hdc_x);
// Print the screen before the printing
Sleep(1000);
}
return 0;
}
As you can see I want to display something on the screen for 1 frame than delete it by redraw the desktop and wait for 1 sec.
My question is how do I save the screen state before the drawing and how do I redraw it again after.
Thank you all and have a nice day!