The SetConsoleMode function sets the input mode of a console's input buffer or the output mode of a console screen buffer.
[Visual Basic]Friend Shared Function SetConsoleMode( _
ByVal hConsoleHandle As Integer, _
ByVal lpConsoleCursorInfo As Integer _
) As Integer
[C#]
internal static int SetConsoleMode(
int hConsoleHandle,
int lpConsoleCursorInfo
);
Parameters
- hConsoleHandle
- Handle to a console input buffer or a screen buffer. The handle must have GENERIC_WRITE access.
- lpConsoleCursorInfo
-
Pointer to a 32-bit variable that indicates the current mode of the specified buffer.
If the hConsoleHandle parameter is an input handle, the mode can be a combination of the following values. When a console is created, all input modes except ENABLE_WINDOW_INPUT are enabled by default.ENABLE_LINE_INPUT The ReadFile or ReadConsole function returns only when a carriage return character is read. If this mode is disabled, the functions return when one or more characters are available. ENABLE_ECHO_INPUT Characters read by the ReadFile or ReadConsole function are written to the active screen buffer as they are read. This mode can be used only if the ENABLE_LINE_INPUT mode is also enabled. ENABLE_PROCESSED_INPUT ctrl+c is processed by the system and is not placed in the input buffer. If the input buffer is being read by ReadFile or ReadConsole, other control keys are processed by the system and are not returned in the ReadFile or ReadConsole buffer. If the ENABLE_LINE_INPUT mode is also enabled, backspace, carriage return, and linefeed characters are handled by the system. ENABLE_WINDOW_INPUT User interactions that change the size of the console screen buffer are reported in the console's input buffer. Information about these events can be read from the input buffer by applications using the ReadConsoleInput function, but not by those using ReadFile or ReadConsole. ENABLE_MOUSE_INPUT If the mouse pointer is within the borders of the console window and the window has the keyboard focus, mouse events generated by mouse movement and button presses are placed in the input buffer. These events are discarded by ReadFile or ReadConsole, even when this mode is enabled.
ENABLE_PROCESSED_OUTPUT Characters written by the WriteFile or WriteConsole function or echoed by the ReadFile or ReadConsole function are parsed for ASCII control sequences, and the correct action is performed. Backspace, tab, bell, carriage return, and linefeed characters are processed. ENABLE_WRAP_AT_EOL_OUTPUT When writing with WriteFile or WriteConsole or echoing with ReadFile or ReadConsole, the cursor moves to the beginning of the next row when it reaches the end of the current row. This causes the rows displayed in the console window to scroll up automatically when the cursor advances beyond the last row in the window. It also causes the contents of the screen buffer to scroll up (discarding the top row of the screen buffer) when the cursor advances beyond the last row in the screen buffer. If this mode is disabled, the last character in the row is overwritten with any subsequent characters.
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.
See Also
ConsoleAttributes Class | ConsoleAttributes Members | Org.Mentalis.Utilities.ConsoleAttributes Namespace