BOOL SetConsoleWindowInfo(hConsoleOutput, fAbsolute, psrctWindowRect) | |||||
HANDLE hConsoleOutput; | /* console to set window size for | */ | |||
BOOL fAbsolute; | /* new coords are absolute or relative | */ | |||
PSMALL_RECT psrctWindowRect; | /* new size in character rows and cols | */ |
The SetConsoleWindowInfo function sets the current size and position of the console window.
hConsoleOutput
Specifies an open console screen buffer handle with GENERIC_WRITE access.
fAbsolute
Indicates whether the values in psrctWindowRect are used as absolute dimensions or as deltas to the current dimensions of the console window.
psrctWindowRect
Points to a SMALL_RECT structure that contains values used to determine the new console window size. If fAbsolute is TRUE, the rectangle specifies the new upper-left and lower-right corners of the window in terms of the screen buffer character cell grid. Otherwise, the values are offsets to the current window corner coordinates.
The SMALL_RECT structure has the following format:
typedef struct _SMALL_RECT { /* srct */
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
} SMALL_RECT, *PSMALL_RECT;
The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.
The function will fail if the specified window rectangle extends beyond the boundaries of the screen buffer.
To determine the current size and position of the console window, use the GetConsoleScreenBufferInfo function. It also returns the maximum size of the console window given the current screen buffer size, the current font, and the display size. The GetLargestConsoleWindowSize function returns the maximum window size given the current font and display, and does not consider the size of the screen buffer.
SetConsoleWindowInfo can be used to scroll the contents of the screen buffer by shifting the position of the window rectangle without changing its size.
ScrollConsoleScreenBuffer, GetConsoleScreenBufferInfo, GetLargestConsoleWindowSize