Skip to content

Latest commit

 

History

History
105 lines (75 loc) · 4.48 KB

setconsolewindowinfo.md

File metadata and controls

105 lines (75 loc) · 4.48 KB
title description author ms.author ms.topic keywords f1_keywords MS-HAID MSHAttr ms.assetid topic_type api_name api_location api_type
SetConsoleWindowInfo function
Sets the current size and position of a console screen buffer's window.
miniksa
miniksa
article
console, character mode applications, command line applications, terminal applications, console api
consoleapi2/SetConsoleWindowInfo
wincon/SetConsoleWindowInfo
SetConsoleWindowInfo
\_win32\_setconsolewindowinfo
base.setconsolewindowinfo
consoles.setconsolewindowinfo
PreferredSiteName:MSDN
PreferredLib:/library/windows/desktop
ad16a8fe-ca91-41d6-93b1-8cce6d54b1da
apiref
SetConsoleWindowInfo
Kernel32.dll
API-MS-Win-Core-Console-l2-1-0.dll
KernelBase.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
DllExport

SetConsoleWindowInfo function

[!INCLUDE not-recommended-banner]

Sets the current size and position of a console screen buffer's window.

Syntax

BOOL WINAPI SetConsoleWindowInfo(
  _In_       HANDLE     hConsoleOutput,
  _In_       BOOL       bAbsolute,
  _In_ const SMALL_RECT *lpConsoleWindow
);

Parameters

hConsoleOutput [in]
A handle to the console screen buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights.

bAbsolute [in]
If this parameter is TRUE, the coordinates specify the new upper-left and lower-right corners of the window. If it is FALSE, the coordinates are relative to the current window-corner coordinates.

lpConsoleWindow [in]
A pointer to a SMALL_RECT structure that specifies the new upper-left and lower-right corners of the window.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The function fails if the specified window rectangle extends beyond the boundaries of the console screen buffer. This means that the Top and Left members of the lpConsoleWindow rectangle (or the calculated top and left coordinates, if bAbsolute is FALSE) cannot be less than zero. Similarly, the Bottom and Right members (or the calculated bottom and right coordinates) cannot be greater than (screen buffer height – 1) and (screen buffer width – 1), respectively. The function also fails if the Right member (or calculated right coordinate) is less than or equal to the Left member (or calculated left coordinate) or if the Bottom member (or calculated bottom coordinate) is less than or equal to the Top member (or calculated top coordinate).

For consoles with more than one screen buffer, changing the window location for one screen buffer does not affect the window locations of the other screen buffers.

To determine the current size and position of a screen buffer's window, use the GetConsoleScreenBufferInfo function. This function also returns the maximum size of the window, given the current screen buffer size, the current font size, and the screen size. The GetLargestConsoleWindowSize function returns the maximum window size given the current font and screen sizes, but it does not consider the size of the console screen buffer.

SetConsoleWindowInfo can be used to scroll the contents of the console screen buffer by shifting the position of the window rectangle without changing its size.

[!INCLUDE no-vt-equiv-user-priv]

Examples

For an example, see Scrolling a Screen Buffer's Window.

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Header ConsoleApi2.h (via WinCon.h, include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

Console Functions

GetConsoleScreenBufferInfo

GetLargestConsoleWindowSize

ScrollConsoleScreenBuffer

Scrolling the Screen Buffer

SMALL_RECT