Name
CreateConsoleWindow -- create a new console window (V10.0)
Synopsis
[id] = CreateConsoleWindow(id, cols, rows, x, y[, parent, rel])
Platforms
Linux, macOS, Windows

Function
This function creates a new window with the given number of columns and rows. The upper left corner of the window is at the coordinates specified by x and y. To create a new full-screen window, just set cols, rows, x and y all to 0. The new window will be given the identifier specified in id. If you pass Nil in id, CreateConsoleWindow() will automatically choose an identifier and return it.

If you set the parent argument to the identifier of an existing console window, the specified window will be set as the parent of the new console window so that the new console window will become a subwindow. You can pass -1 in parent to set the default console window as the parent. If you set rel to True, the x and y coordinates will be interpreted as relative to the parent window's origin instead of relative to the screen's origin.

Once you have created the console window, you can then use SelectConsoleWindow() to make it the active console window. See SelectConsoleWindow for details.

Note that a console window is not the same as a window on your desktop. A console window merely is a certain area in the console that is regarded as an own window. This makes it easier to create textual user interfaces because you can divide your console screen into several windows and then all drawing is automatically clipped at the window edges.

You must enable advanced console mode using EnableAdvancedConsole() before you can use this function. See EnableAdvancedConsole for details.

Inputs
id
id for the console window or Nil for auto id selection
cols
number of columns for the window
rows
number of rows for the window
x
left window offset
y
top window offset
parent
optional: identifier of a console window to be used as a parent (defaults to -1 which means the screen is the parent)
rel
optional: whether or not x and y specify relative offsets (defaults to False)
Results
id
optional: identifier of the new console window; will only be returned if you pass Nil as argument 1 (see above)
Example
EnableAdvancedConsole()
w, h = GetConsoleSize()
CreateConsoleWindow(1, 20, 20, (w - 20) / 2, (h - 20) / 2)
SelectConsoleWindow(1)
DrawConsoleBorder()
RefreshConsole()
The code above creates a new 20x20 window, draws a border around it and centers it on the screen.

Show TOC