简体   繁体   English

全屏运行C ++控制台程序

[英]Running a C++ Console Program in full screen

How to run a C++ Console Program in full screen ? 如何全屏运行C ++控制台程序? , using VS2008 ,使用VS2008

Just tested this with cl fullscreen.cpp : 刚用cl fullscreen.cpp测试了这个:

#include <iostream>
#include <windows.h>

#pragma comment(lib, "user32")

int main()
{
    ::SendMessage(::GetConsoleWindow(), WM_SYSKEYDOWN, VK_RETURN, 0x20000000);

    std::cout << "Hello world from full screen app!" << std::endl; 
    std::cin.get();
}

Unfortunatelly it had duplicated the text on the second monitor :) 不幸的是,它在第​​二台显示器上复制了文字:)

try: 尝试:

#include <iostream>

using namespace std;

int main(){
system("mode 650");

system("pause");
return 0;
}
#include <windows.h>

SetConsoleDisplayMode(GetStdHandle(STD_OUTPUT_HANDLE),CONSOLE_FULLSCREEN_MODE,0);

There are not a lot of video adapters around these days that still support this. 目前还没有很多视频适配器仍然支持这一点。 Run cmd.exe and press Alt+Enter. 运行cmd.exe并按Alt + Enter。 If you get a message box that says "This system does not support fullscreen mode" then you're done. 如果您收到一条消息框,显示“此系统不支持全屏模式”,那么您就完成了。 If it does switch to full screen then you can use SetConsoleDisplayMode() in your main() function. 如果它确实切换到全屏,那么您可以在main()函数中使用SetConsoleDisplayMode()。 Of course, you don't know what your customer's machine is like, best not to pursue this. 当然,你不知道客户的机器是什么样的,最好不要追求这个。

对于全屏窗口模式: ShowWindow(GetConsoleWindow(), SW_MAXIMIZE);

Just add this line (anywhere) before your output, 只需在输出之前添加此行(任何位置),

system("mode 650");

Such as, 如,

#include<bits/stdc++.h>
using namespace std;

int main(){

    system("mode 650");
    cout<<"Hey, this words are shown in full screen console! "<<endl;
    return 0;
}

That's what I'm using: 这就是我正在使用的:

system("mode con COLS=700");
ShowWindow(GetConsoleWindow(),SW_MAXIMIZE);
SendMessage(GetConsoleWindow(),WM_SYSKEYDOWN,VK_RETURN,0x20000000);

It removes the scrollbar :D 它删除了滚动条:D

Just a workaround: You could use some sort of earlier DOS video modi, for example... 只是一个解决方法:你可以使用某种早期的DOS视频modi,例如......

asm
{
    mov     ax, 13h
    push    bp
    int     10h
    pop     bp
}

...to have a resolution of 320x200 pixels. ...具有320x200像素的分辨率。

But I'm not sure if this would work for a windows application... Probably not! 但我不确定这是否适用于Windows应用程序...可能不会!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM