Thread: How to redraw the desktop screen

  1. #1
    Registered User
    Join Date
    Jun 2017
    Posts
    2

    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!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to redraw the desktop screen
    By peewe in forum Windows Programming
    Replies: 1
    Last Post: 06-11-2017, 11:31 AM
  2. How to redraw the desktop screen
    By peewe in forum C++ Programming
    Replies: 0
    Last Post: 06-11-2017, 03:17 AM
  3. sdl screen resize and redraw problem
    By mad_muppet in forum Game Programming
    Replies: 1
    Last Post: 08-09-2008, 08:55 PM
  4. Returning from fullscreen mode, redraw desktop
    By darksaidin in forum Windows Programming
    Replies: 4
    Last Post: 08-23-2003, 06:02 PM
  5. Graphic screen redraw
    By bob5845 in forum C++ Programming
    Replies: 0
    Last Post: 04-09-2002, 08:45 PM

Tags for this Thread