1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <Windows.h>
#include <iostream>
const int WIDTH=50;
const int HEIGHT=20;
int main(void){
char hold;
HANDLE write_handle=GetStdHandle(STD_OUTPUT_HANDLE);
SMALL_RECT window_size={0,0,WIDTH-1,HEIGHT-1};
COORD screen_buffer={WIDTH,HEIGHT};
SetConsoleWindowInfo(write_handle,TRUE,&window_size);
SetConsoleScreenBufferSize(write_handle,screen_buffer);
SetConsoleTitle("Test");
//////////////////
CHAR_INFO some_char;
some_char.Char.AsciiChar='P';
some_char.Attributes=FOREGROUND_BLUE | FOREGROUND_RED |
FOREGROUND_INTENSITY;
SMALL_RECT window_buffer={0,0,WIDTH,HEIGHT};
COORD char_buffer_size={1,1};
COORD char_pos;
char_pos.X=0;//problem here when >0
char_pos.Y=0;//problem here when >0
WriteConsoleOutput(write_handle, &some_char, char_buffer_size, char_pos, &window_buffer);
std::cin>>hold;
return 0;
}
| |