Код:
#include <windows.h>
#include <stdio.h>
extern "C" WINBASEAPI HWND WINAPI GetConsoleWindow ();
int main()
{
HWND hWindow = NULL; // дескриптор окна
HDC hDeviceContext; // контекст устройства
HPEN hPen; // дескриптор пера
HGDIOBJ hObject; // дескриптор GDI объекта
// получаем дескриптор окна
hWindow = GetConsoleWindow();
if (hWindow == NULL)
{
printf("Get console window failed.\n");
return 1;
}
else
printf("Cet console window is done.\n");
// получаем контекст устройства
hDeviceContext = GetDC(hWindow);
// создаем перо
hPen = CreatePen(PS_SOLID, 10, RGB(0, 255, 0));
// устанавливает перо
hObject = SelectObject(hDeviceContext, hPen);
// рисуем x
MoveToEx(hDeviceContext, 100, 200, NULL);
LineTo(hDeviceContext, 200, 100);
MoveToEx(hDeviceContext, 200, 200, NULL);
LineTo(hDeviceContext, 100, 100);
//y
MoveToEx(hDeviceContext, 300, 200, NULL);
LineTo(hDeviceContext, 400, 100);
MoveToEx(hDeviceContext, 300, 100, NULL);
LineTo(hDeviceContext, 350, 150);
//й
MoveToEx(hDeviceContext, 500, 100, NULL);
LineTo(hDeviceContext, 500, 200);
LineTo(hDeviceContext, 600, 100);
LineTo(hDeviceContext, 600, 200);
MoveToEx(hDeviceContext, 540, 50, NULL);
LineTo(hDeviceContext, 560, 70);
LineTo(hDeviceContext, 580, 50);
// востанавливает старый объект
SelectObject(hDeviceContext, hObject);
// освобождаем объекты
DeleteObject(hPen);
ReleaseDC(hWindow, hDeviceContext);
return 0;
}