As you probably know, if you open up the command prompt and press alt + enter, the window will change from normal to full screen mode or full screen to normal mode. Basically, all the function does is creates a keyboard event / sends the keys to the program, i.e. sort of pretends that the user is holding alt + enter and then letting go of them. I''m not sure whether this is the "proper" way to do it, but it seems like a little hax.
Because alt + enter does the inverse - i.e. if you press alt + enter whilst in normal mode, it changes the command prompt to full screen mode, and vice versa - you can use the same command to change between modes. I would, then, change the function name:
#include <iostream>
#include <windows.h>
void ChangeScreenMode();
void ChangeScreenMode()
{
keybd_event(VK_MENU, 0x38, 0, 0); // hold alt key down
keybd_event(VK_RETURN, 0x1c, 0, 0); // hold enter key down
keybd_event(VK_RETURN, 0x1c, KEYEVENTF_KEYUP, 0); // release enter
keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0); // release alt
}
int main()
{
ChangeScreenMode(); // if started in normal, now in full screen - vice versa
std::cout << "Welcome to full screen mode!\n\n";
system("PAUSE");
ChangeScreenMode(); // if was in full screen, now in normal - vice versa
std::cout << "Welcome to normal mode!\n\n";
system("PAUSE");
return 0;
}
As I said, as far as I can see this is a hax. I''m sure that there must be some proper Windows API functions for you to change the mode and check the mode. I would recommend that you have a look on
MSDN for these functions; I can''t be bothered.
[
Google ||
Start Here ||
ACCU ||
MSDN ||
STL ||
GameCoding ||
BarrysWorld ||
E-Mail Me ]