 |
JLI Spieleprogrammierung
|
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
Autor |
Nachricht |
GreveN JLI Master

Alter: 38 Anmeldedatum: 08.01.2004 Beiträge: 901 Wohnort: Sachsen - Dresden Medaillen: Keine
|
Verfasst am: 06.08.2004, 15:01 Titel: Konsolenanwendung im Fullscreenmodus? |
|
|
Hi @all,
ich hab mich mal damit beschäftigt wie ich eine Konsolenanwendung in den Fullscreenmodus schalten kann. Scheinbar gibts dafür ja keine Funktion...
Das einzige was ich gefunden habe sind Code Snippets wie das hier:
Code: | #include <windows.h>
#include <stdio.h>
#include <conio.h>
// prototypes
BOOL FullScreenConsole9x(void);
BOOL FullScreenConsoleNT(void);
// ---------------------------------------------------------------------------
BOOL FullScreenConsole9x(void)
{
BOOL ok = FALSE;
// console finding guid
// a unique number to identify this console - replace this with your own
#define CON_GUID TEXT("CON_GUID-{68E311EF-BF32-4b0f-8D35-E84E4A463096}")
// hwnd for console window
HWND hConWnd = NULL;
// magic command
WPARAM magic = 57359;
// buffer for storing a substitute title
TCHAR szTempTitle[] = CON_GUID;
// buffer for storing current console title
TCHAR szTempString[MAX_PATH];
// obtain the current console title
if( GetConsoleTitle(szTempString, sizeof(szTempString)/sizeof(TCHAR) ) )
{
// replace the current title with substitute title
SetConsoleTitle(szTempTitle);
// give it a chance to set in
Sleep(50);
// locate the console window
// console window class on W9x is "tty"
hConWnd = FindWindow(TEXT("tty"), szTempTitle);
// restore the original console title
SetConsoleTitle(szTempString);
}
// verify the console hwnd
if ( hConWnd != NULL ) {
// pause before changing to fullscreen
Sleep(450);
// this method works by faking a keyboard command
SendMessage(hConWnd,WM_COMMAND,magic,0);
ok = TRUE;
}
return ok;
}
// ---------------------------------------------------------------------------
BOOL FullScreenConsoleNT(void)
{
// typedef function pointer for undocumented API
typedef BOOL WINAPI (*SetConsoleDisplayModeT)(HANDLE,DWORD,DWORD*);
// declare one such function pointer
SetConsoleDisplayModeT SetConsoleDisplayMode;
// load kernel32.dll
HINSTANCE hLib = LoadLibrary("KERNEL32.DLL");
if ( hLib == NULL ) {
// highly unlikely but good practice just the same
return FALSE;
}
// assign procedure address to function pointer
SetConsoleDisplayMode = ( SetConsoleDisplayModeT )
GetProcAddress(hLib,"SetConsoleDisplayMode");
// check if the function pointer is valid
// since the function is undocumented
if ( SetConsoleDisplayMode == NULL ) {
// play nice with windows
FreeLibrary(hLib);
return FALSE;
}
DWORD newmode = 1; // fullscreen mode
DWORD oldmode;
// get handle to stdout
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
// pause before changing to fullscreen
Sleep(500);
// set full screen mode
SetConsoleDisplayMode(hStdOut,newmode,&oldmode);
// play nice with windows
FreeLibrary(hLib);
return TRUE;
}
// ---------------------------------------------------------------------------
int main(void)
{
OSVERSIONINFO VerInfo;
ZeroMemory(&VerInfo,sizeof(VerInfo));
VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
GetVersionEx(&VerInfo);
// Why a switch? because I felt like switching... har har
switch ( VerInfo.dwPlatformId ) {
case VER_PLATFORM_WIN32_NT :
FullScreenConsoleNT();
break;
case VER_PLATFORM_WIN32_WINDOWS :
FullScreenConsole9x();
break;
default:
break;
}
// issue a report
printf("This is a test.\nHit enter to exit");
// wait for keyboard hit
getch();
return 0;
} |
...die z.B. das Drücken der Tastenkombo Alt + F4 vorgaukeln, allerdings finde ich diese Variante nicht allzu schön und sauber.
Kennt jemand noch ne andere Möglichkeit?
btw: Das hier würde bestimmt auch in die FAQ gehören...  |
|
Nach oben |
|
 |
TheMillenium Dark JLI'ler
Anmeldedatum: 21.07.2002 Beiträge: 1427 Wohnort: World Medaillen: Keine
|
Verfasst am: 06.08.2004, 15:48 Titel: |
|
|
Meinst du maximiert oder richtig Fullscreen? Ich weiß es nicht, weil ich nur Fehler bekomme wenn ich den Code ausführe...
edit: Ok Fullscreen. Rechtsklick auf das Fenster, Standardwerte->Fullscreen
Jetzt müsste man nur wissen, wie man die beim Starten des Programm umstellt und wie man die wieder kurz vorm Beenden zurücksetzzt... _________________ The source of all power is in its destiny... |
|
Nach oben |
|
 |
GreveN JLI Master

Alter: 38 Anmeldedatum: 08.01.2004 Beiträge: 901 Wohnort: Sachsen - Dresden Medaillen: Keine
|
Verfasst am: 06.08.2004, 19:59 Titel: |
|
|
TheMillenium hat Folgendes geschrieben: | Meinst du maximiert oder richtig Fullscreen? |
Richtig Fullscreen... |
|
Nach oben |
|
 |
|
|
Du kannst keine Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum nicht antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen.
|
Powered by phpBB © 2001, 2005 phpBB Group Deutsche Übersetzung von phpBB.de
|