- Console Window Manipulation 大概分成這四種
The active screen buffer includes data displayed by the console window.
- SetConsoleTitle
SetConsoleTitle
changes the console window’s title. Pass it a null-terminated string:
|
|
- GetConsoleScreenBufferInfo
GetConsoleScreenBufferInfo
returns information about the current state of the console window. It has two parameters:a handle to the console screen
, anda pointer to a structure
that is filled in by the function:
|
|
- CONSOLE_SCREEN_BUFFER_INFO
|
|
- dwSize -size of the screen buffer (char columns and rows)
- dwCursorPos -cursor location
- wAttributes -colors of characters in console buffer
- srWindow -coords of console window relative to screen buffer
- maxWinSize -maximum size of the console window
- COORD and SMALL_RECT
- The
COORD structure
specifies X and Y screen coordinates in character measurements, which default to0-79
and0-24
. - The
SMALL_RECT structure
specifies awindow’s location
in character measurements.
|
|
|
|
- SetConsoleWindowInfo
SetConsoleWindowInfo
lets youset the size and position of the console window
relative to its screen buffer.- Prototype:
|
|
- SetConsoleScreenBufferSize
SetConsoleScreenBufferSize
lets you set the screen buffer size to X columns by Y rows.- Prototype:
|
|
- Controlling the Cursor
returns the size and visibility of the console cursor
sets the size and visibility of the cursor
sets the X, Y position of the cursor
- CONSOLE_CURSOR_INFO
Structure containing information about the console’s cursor size and visibility:
|
|
- SetConsoleTextAttribute
- Sets the foreground and background colors of all subsequent text written to the console.
- Prototype:
|
|
- WriteConsoleOutputAttribute
- Copies an array of attribute values to consecutive cells of the console screen buffer, beginning at a specified location.
- Prototype:
|
|
- WriteConsoleOutputCharacter
- Copy characters to consecutive cells of the console screen buffer, beginning at a specified location.
- Prototype:
|
|
- Example : WriteColors Program
- Creates an array of characters and an array of attributes, one for each character
- Copies the attributes to the screen buffer
- Copies the characters to the same screen buffer cells as the attributes
- (starts in row 2, column 10)
|
|
- GetLocalTime, SetLocalTime
GetLocalTime
returns the date and current time of day, according to the system clock.SetLocalTime
sets the system’s local date and time.
|
|
- GetTickCount, Sleep
GetTickCountfunction
returns the number of milliseconds that have elapsed since the system was started.Sleep
pauses the current program for a specified number of milliseconds.
|
|
- SYSTEMTIME Structure
SYSTEMTIME
is used by date and time-related Windows API functions:
|
|
- Example : Calculate Elapsed Time (Timer.asm)
|
|