Загрузка данных


#include "stdio.h"
#include <iostream>
#include <Windows.h>
#include <windowsx.h>
#include <tchar.h>
using namespace std;


HWND hWnd = GetConsoleWindow();
HDC hDC = GetDC(hWnd);//Получаем контекст устройства по полученному дескриптору

void RectangleShow(COLORREF Color, int iCenterX, int iCenterY, int iw, int ih)
{
	HPEN hPen = CreatePen(PS_SOLID, 1, Color);//установка пера
	HBRUSH hBrush = GetStockBrush(NULL_BRUSH);
	SelectObject(hDC, hPen);
	SelectObject(hDC, hBrush);

	Rectangle(hDC, iCenterX, iCenterY, iCenterX + iw, iCenterY + ih);

	DeleteObject(hBrush);
	DeleteObject(hPen);
}


// Головная функция
int main()
{
	int ix = 1;
	int x = 100, y = 50;
	COLORREF color = GetPixel(hDC, 0, 0);//получение цвета пикселя с заданными коородинатами
	RectangleShow(RGB(255, 0, 0), ix, 0, x, y);
	std::cin.get();


	for (; ix < 300; )
	{
		RectangleShow(color, ix, 0, x, y);
		ix += 10;
		x = 50 + rand() % 50;
		y = 50 + rand() % 50;
		RectangleShow(RGB(255, 0, 0), ix, 0, x, y);
		Sleep(300);
	}
	std::cin.get();
	return 0;
}