September 22, 2009

Full Screen Code

//----------------------------------------------------------------------------
// File: fullscr.txt
//----------------------------------------------------------------------------
// You are allowed to distribute this document unmodified for free,
// without paying me any fee.
// The information in this document is provided AS IS,
// without any warranties or guarantees.
//
// All undocumented Windows features used/described in this document
// are discovered by me, Nick N. Repin.
//
// Copyright (c) Nikolay N. Repin (Nick N. Repin), 1998
//----------------------------------------------------------------------------
// Toggles console application to the full-screen mode.
// [This file consist of several modules]
//----------------------------------------------------------------------------



//*********************************************************************
// Part 1. Windows 95/98
//*********************************************************************

#include
#include

void main(void) {
// Find our console window (may be any other code here)
char con[120];
GetConsoleTitle(con,sizeof(con));
HWND w=FindWindow("tty",con);

cprintf("Test");
getch(); // Not necessary - just to test

// Set full screen mode
SendMessage(w,WM_COMMAND,57359,0);

getch(); // Not necessary - just to test
}

//*********************************************************************
// Part 2. Windows NT 4.0
//*********************************************************************

#include
#include
#include
#include

typedef BOOL WINAPI (*GetConsoleDisplayModeT)(DWORD*);
typedef BOOL WINAPI (*SetConsoleDisplayModeT)(HANDLE,DWORD,DWORD*);

GetConsoleDisplayModeT GetConsoleDisplayMode;
SetConsoleDisplayModeT SetConsoleDisplayMode;

void main(int argc, char* argv[])
{
HINSTANCE hLib=LoadLibrary("KERNEL32.DLL");
SetConsoleDisplayMode=(SetConsoleDisplayModeT)
GetProcAddress(hLib,"SetConsoleDisplayMode");
GetConsoleDisplayMode=(GetConsoleDisplayModeT)
GetProcAddress(hLib,"GetConsoleDisplayMode");

// It's possible to use GetStdHandle()
HANDLE h=CreateFile("CONOUT$",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ |
FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,0);

DWORD oldmode;

/*DWORD mode;
GetConsoleDisplayMode(&mode);
cout<<"Previous mode="<<1) {
DWORD newmode=atoi(argv[1]);
cout<<"Setting mode="<<
cout<<"Result="<<
cout<<"Oldmode="<<
}

GetConsoleDisplayMode(&mode);
cout<<"Current mode="<<
*/

cprintf("Test");
Sleep(5000); // Not necessary - just to test

// Set full screen mode
SetConsoleDisplayMode(h,1,&oldmode);

getch(); // Not necessary - just to test

}
//- EOF: fullscr.txt ----------------------------------------------------------
Disqus Comments