Fullscreen
Solved
Flipody
-
blib -
blib -
Hello everyone!
Actually, I have a console application and I would like it to launch in full screen instead of in a window. I don't want the user to have to press Alt+Enter. How can I do that? A script to automatically do Alt+Enter? I'm open to it but I would need help, please...
Thank you in advance.
Have a great day everyone.
Flipody
Actually, I have a console application and I would like it to launch in full screen instead of in a window. I don't want the user to have to press Alt+Enter. How can I do that? A script to automatically do Alt+Enter? I'm open to it but I would need help, please...
Thank you in advance.
Have a great day everyone.
Flipody
3 answers
Voici deux bouts de code C qui permettent d'ouvrir automatiquement la console en plein écran.
(moi j'ai DEV-C++ et ces codes fonctionnent bien).
#include<windows.h>
int main(int argc , char *argv[])
{
typedef BOOL (WINAPI *PFONCTION) (HANDLE,DWORD,PCOORD);
HMODULE hDLL=LoadLibrary("kernel32.dll");
PFONCTION SetDisplayMode = (PFONCTION) GetProcAddress(hDLL,"SetConsoleDisplayMode");
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
SetDisplayMode (hconsole,1,&coord);
//Suite du code...
}
//OU la deuxieme solution qui simule ALT et ENTREE
#include<windows.h>
int main(int argc , char *argv[])
{
keybd_event(VK_MENU,0x38,0,0); //Appuie sur ALT
keybd_event(VK_RETURN,0x1c,0,0); //Appuie ENTREE
keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0); // Relache ENTREE
keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0); //Relache ALT
//Suite du code...
}
(moi j'ai DEV-C++ et ces codes fonctionnent bien).
#include<windows.h>
int main(int argc , char *argv[])
{
typedef BOOL (WINAPI *PFONCTION) (HANDLE,DWORD,PCOORD);
HMODULE hDLL=LoadLibrary("kernel32.dll");
PFONCTION SetDisplayMode = (PFONCTION) GetProcAddress(hDLL,"SetConsoleDisplayMode");
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
SetDisplayMode (hconsole,1,&coord);
//Suite du code...
}
//OU la deuxieme solution qui simule ALT et ENTREE
#include<windows.h>
int main(int argc , char *argv[])
{
keybd_event(VK_MENU,0x38,0,0); //Appuie sur ALT
keybd_event(VK_RETURN,0x1c,0,0); //Appuie ENTREE
keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0); // Relache ENTREE
keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0); //Relache ALT
//Suite du code...
}
A priori, from your code you don't have access to the window... the only solution is to change the default parameters of the console under Windows...
otherwise, from the program, it becomes more complicated... you'll have to look for the default parameters of the console and modify them through the program by writing to the registry... but that becomes annoying... last solution, you don't go through the Windows console... you create a program that runs on your own console, a simple window where you will scroll the text...
otherwise, from the program, it becomes more complicated... you'll have to look for the default parameters of the console and modify them through the program by writing to the registry... but that becomes annoying... last solution, you don't go through the Windows console... you create a program that runs on your own console, a simple window where you will scroll the text...
It works wonderfully! I had been looking for how to do it for a month...
Thank you!
It was posted... 15 years ago!!!!
#include <windows.h>
int main ()
{
HWND hwnd=GetForegroundWindow();
ShowWindow(hwnd,SW_MAXIMIZE);
.
.
. //rest of the code
return 0;
}
It works for me, I use CodeBlocks, and there's no problem ;)
Note: this code only works on Windows (like yours, because of windows.h)