{COORD dwSize;
COORD dwCursorPosition;
WORD wAttributes;
SMALL_RECT srWindow;
COORD dwMaximumWindowSize;
} CONSOLE_SCREEN_BUFFER_INFO, *PCONSOLE_SCREEN_BUFFER_INFO;
dwCursorPosition, . GetConsoleScreenBufferInfo
BOOL GetConsoleScreenBufferInfo(HANDLE hConsOut, CONSOLE_SCREEN_BUFFER_INFO* lpConsoleScreenBufferInfo);
#include <windows.h>
#include <wincon.h>
#include <stdio.h>
void main()
{char text1[]="Text for example\t";
DWORD actlen;
HANDLE hstdout;
CONSOLE_SCREEN_BUFFER_INFO consinfo;
COORD coorpos;
hstdout=GetStdHandle(STD_OUTPUT_HANDLE);
if(hstdout==INVALID_HANDLE_VALUE)ExitProcess(0);
GetConsoleScreenBufferInfo(hstdout,&consinfo);
coorpos.Y=(short)(consinfo.dwCursorPosition.Y+5);
coorpos.X=(short)(consinfo.dwCursorPosition.X+25);
SetConsoleCursorPosition(hstdout,coorpos);
WriteConsole(hstdout,text1,sizeof(text1),&actlen,NULL);
getchar();
CloseHandle(hstdout);
ExitProcess(0);
}
FillConsoleOutputCharacterA, FillConsoleOutputAttribute.
BOOL FillConsoleOutputCharacterA(HANDLE hConsOut, CHAR character, WORD len, COORD pos, DWORD* actlen);
BOOL FillConsoleOutputAttribute(HANDLE hConsOut, WORD attr, WORD len,
COORD pos, DWORD* actlen);
, , , , len , actlen . , . pos , .
, wincon.h.
#include <windows.h>
//#include <wincon.h>
#include <stdio.h>
void main()
{HANDLE hstdout;
char ch='@';
char ch2='$';
COORD pos;
DWORD actlen;
WORD attri=0x3e;
hstdout=GetStdHandle(STD_OUTPUT_HANDLE);
if(hstdout==INVALID_HANDLE_VALUE)
{printf("Error GetStdHandle\n");exit(-1);}
pos.X=0;pos.Y=9;
FillConsoleOutputCharacterA(hstdout,ch,400,pos,&actlen);
pos.X=2;pos.Y=14;
FillConsoleOutputAttribute(hstdout,attri,200,pos,&actlen);
pos.X=0;pos.Y=14;
FillConsoleOutputCharacterA(hstdout,ch2,300,pos,&actlen);
getchar();
CloseHandle(hstdout);
ExitProcess(0);
}
BOOL WriteConsoleOutputCharacterA(HANDLE hConsOut, CSTR* text, DWORD len, COORD pos, DWORD* actlen);
|
|
, , .
#include <windows.h>
//#include <wincon.h>
#include <stdio.h>
void main()
{char text1[]="Color text for example";
COORD pos;
DWORD actlen;
HANDLE hstdout;
short attri=0x2e;
int len=sizeof(text1);
hstdout=GetStdHandle(STD_OUTPUT_HANDLE);
if(hstdout==INVALID_HANDLE_VALUE)
{printf("Error GetStdHandle\n");exit(-1);}
pos.X=20;pos.Y=9;
FillConsoleOutputAttribute(hstdout,attri,len,pos,&actlen);
WriteConsoleOutputCharacterA(hstdout,text1,len,pos,&actlen);
getchar();
CloseHandle(hstdout);
ExitProcess(0);
}
BOOL WriteConsoleOutputA(HANDLE hConsOut, CHAR_INFO* cells, COORD dwBufferSize, COORD dwBufferCoord, SMALL_RECT* rect);
. , , c . ( , OS/2) , . cells. CHAR_INFO,
Typedef struct CHAR_INFO
Union
{WCHAR UnicodeChar;
CHAR AsciiChar;
} Char;
WORD Attributes;
} CHAR_INFO, *PCHAR_INFO;
dwBufferSize : , dwBufferCoord , . rect , .