One solution you can do is to create an infinite loop, then inside infinite loop, the set pixel is being called here.
Kindly look at the sample code (based on what you have given):
#define _WIN32_WINNT 0x0500 #include <windows.h> #include <iostream> using namespace std; HWND consoleWindow = GetConsoleWindow(); // Get a console handle int main() { HDC consoleDC = GetDC(consoleWindow); // Get a handle to device context while(true){ SetPixel(consoleDC, 20, 20, RGB(255, 255, 255)); SetPixel(consoleDC, 20, 21, RGB(255, 255, 255)); SetPixel(consoleDC, 20, 22, RGB(255, 255, 255)); SetPixel(consoleDC, 20, 23, RGB(255, 255, 255)); SetPixel(consoleDC, 21, 20, RGB(255, 255, 255)); SetPixel(consoleDC, 21, 21, RGB(255, 255, 255)); SetPixel(consoleDC, 21, 22, RGB(255, 255, 255)); SetPixel(consoleDC, 21, 23, RGB(255, 255, 255)); SetPixel(consoleDC, 22, 20, RGB(255, 255, 255)); SetPixel(consoleDC, 22, 21, RGB(255, 255, 255)); SetPixel(consoleDC, 22, 22, RGB(255, 255, 255)); SetPixel(consoleDC, 22, 23, RGB(255, 255, 255)); SetPixel(consoleDC, 23, 20, RGB(255, 255, 255)); SetPixel(consoleDC, 23, 21, RGB(255, 255, 255)); SetPixel(consoleDC, 23, 22, RGB(255, 255, 255)); SetPixel(consoleDC, 23, 23, RGB(255, 255, 255)); } ReleaseDC(consoleWindow, consoleDC); cin.ignore(); return 0; }
Not so perfect solution, as when you scroll down the console, the pixel is being replicated and looks like a trailing dot, but it gives you the idea on how to get things done. :)
SetPixelfrom?