The 25*80 you are referring to is not in pixels, but in characters. If you wish to use SetPixel
to modify the console window, you first have to get the size of the client area, which can be done with GetClientRect
.
The following would draw a red crosshair over the client area of your console window:
HWND myconsole = GetConsoleWindow();
HDC mydc = GetDC(myconsole);
RECT rect;
GetClientRect(myconsole, &rect);
for(int i = 0; i < rect.bottom - rect.top; ++i)
SetPixel(mydc, (rect.right - rect.left) / 2, i, RGB(255, 0, 0));
for(int i = 0; i < rect.right - rect.left; ++i)
SetPixel(mydc, i, (rect.bottom - rect.top) / 2, RGB(255, 0, 0));
Note that the console window can (and will) overwrite your drawings whenever it considers a redraw to be necessary.