SetConsoleDisplayMode function
Applies to: desktop apps only
Sets the display mode of the specified console screen buffer.
Syntax
BOOL WINAPI SetConsoleDisplayMode( __in HANDLE hConsoleOutput, __in DWORD dwFlags, __out_opt PCOORD lpNewScreenBufferDimensions );
Parameters
- hConsoleOutput [in]
-
A handle to the console screen buffer.
- dwFlags [in]
-
The display mode of the console. This parameter can be one or more of the following values.
Value Meaning - CONSOLE_FULLSCREEN_MODE
- 1
Text is displayed in full-screen mode.
- CONSOLE_WINDOWED_MODE
- 2
Text is displayed in a console window.
- lpNewScreenBufferDimensions [out, optional]
-
A pointer to a COORD structure that receives the new dimensions of the screen buffer, in 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.
Requirements
|
Minimum supported client | Windows XP |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 2/3/2012
Community Content
Jim Michaels
"function not defined in wincon.h" - reason why
apparently it is up to the developer to #define _WIN32_WINNT appropriately at compile time. you will need to read the header for wincon.h to get an idea what it is doing. certain functions are enabled for certain versions of windows. this function is enabled for Windows XP/2003 minimum I believe, but not windows 2000, hence the version >= 0x0501. I had not understood this part of the headers until someone explained it to me.
for instance, if your app requires windows 7, you must do at the top of your files just before the #includes:
#define _WIN32_WINNT 0x0601
see the chart at http://jesusnjim.com/programming/GetVersionEx.html it should give you an idea what the version numbers should be. I have also written a program called GetVersionEx that calls GetVersionEx() and dumps the information in human-readable format (2 formats, actually).
for instance, if your app requires windows 7, you must do at the top of your files just before the #includes:
#define _WIN32_WINNT 0x0601
see the chart at http://jesusnjim.com/programming/GetVersionEx.html it should give you an idea what the version numbers should be. I have also written a program called GetVersionEx that calls GetVersionEx() and dumps the information in human-readable format (2 formats, actually).
MartinNvP
This function not defined in wincon.h , with MSVC 2005
I can clearly see the GetConsoleDisplayMode() function in wincon.h
But the corresponding SetConsoleDisplayMode() function is not present.
You may need to use:
int NT_SetConsoleDisplayMode(HANDLE hOutputHandle, DWORD dwNewMode)
{
typedef BOOL (WINAPI *SCDMProc_t) (HANDLE, DWORD, LPDWORD);
SCDMProc_t SetConsoleDisplayMode;
HMODULE hKernel32;
BOOL bFreeLib = FALSE, ret;
const char KERNEL32_NAME[] = "kernel32.dll";
hKernel32 = GetModuleHandleA(KERNEL32_NAME);
if (hKernel32 == NULL)
{
hKernel32 = LoadLibraryA(KERNEL32_NAME);
if (hKernel32 == NULL)
return FALSE;
bFreeLib = true;
}//if
SetConsoleDisplayMode =
(SCDMProc_t)GetProcAddress(hKernel32, "SetConsoleDisplayMode");
if (SetConsoleDisplayMode == NULL)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
ret = FALSE;
}//if
else
{
DWORD dummy;
ret = SetConsoleDisplayMode(hOutputHandle, dwNewMode, &dummy);
}//else
if (bFreeLib)
FreeLibrary(hKernel32);
return ret;
}