QUOTE
This is my first time asking a question, so go easy on me...
Am I really that rude?
You can use two techniques to set the console in fullscreen mode.
- SetConsoleDisplayMode
- Simulating the Alt+Enter KeyStrokes (using SendInput() or keybd_event()
I've provided the code for both these methods.
Which compiler are you using?
I'm not sure if Dev C++ supports this, although Borland,VC++ and others do.
MSDN Recommends usage of SendInput rather than keybd_event.
But I'm not sure how it can be done using SendInput, so i've implemented it using the latter.
Here's the code.
CODE
#include <windows.h>
#include <conio.h>
#include <iostream.h>
void AltEnter()
{
keybd_event(VK_MENU,0x38,0,0);
keybd_event(VK_RETURN,0x1c,0,0);
keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
}
BOOL 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;
}
SetConsoleDisplayMode =
(SCDMProc_t)GetProcAddress(hKernel32, "SetConsoleDisplayMode");
if (SetConsoleDisplayMode == NULL)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
ret = FALSE;
}
else
{
DWORD tmp;
ret = SetConsoleDisplayMode(hOutputHandle, dwNewMode, &tmp);
}
if (bFreeLib)
FreeLibrary(hKernel32);
return ret;
}
int main( void )
{
int x;
cout<<"1) Using SetConsoleDisplayMode (Press Return)\n";
NT_SetConsoleDisplayMode( GetStdHandle( STD_OUTPUT_HANDLE ), 1 );
getch();
NT_SetConsoleDisplayMode( GetStdHandle( STD_OUTPUT_HANDLE ), 0 );
cout<<"2) Simulating Alt+Enter KeyStrokes (Press Return)\n";
getch();
AltEnter();
getch();
return 0;
}