Create "drawings" with windows API

3

Hello, I need help with the windows API when it comes to manipulating "drawings". My problem is that resizing or minimizing the window disappears everything that was printed on the console. This is what I have already been able to do about this subject:

#include <Windows.h>
#include<windows.h>
#include<iostream>

using namespace std;

int main() {
    cin.ignore();
    //Get a console handle
    HWND myconsole = GetConsoleWindow();
    //Get a handle to device context
    HDC mydc = GetDC(myconsole);

    //Choose any color
    COLORREF COLOR= RGB(255,255,255);
    HPEN hBluePen = CreatePen(PS_SOLID, 1, COLOR);
    HGDIOBJ hPen = SelectObject(mydc, hBluePen);

    //Lines
    MoveToEx(mydc, 10, 40, NULL);
    LineTo(mydc, 44, 10);
    LineTo(mydc, 78, 40);

    //Rectangles
    cin.ignore();
    Rectangle(mydc, 16, 36, 72, 70);
    Rectangle(mydc, 60, 80, 80, 90);

    //Elipse
    cin.ignore();
    Ellipse(mydc, 40, 55, 48, 65);

    ReleaseDC(myconsole, mydc);
    cin.ignore();
    return 0;
}

This draws 5 objects, two lines, two rectangles and one ellipse.

EDIT:

I tried to approach with WindowProc but also to no avail. I leave the code below:

        LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
            switch (message) {
                case WM_PAINT:
                    cout << "text";
                default:
                    return DefWindowProc(hwnd, message, wParam, lParam);
           }
      }
    
asked by anonymous 06.06.2018 / 17:22

0 answers