在任何Windows verison上

时间:2018-04-09 21:43:51

标签: c++ winapi console

所以我试图让一个控制台应用程序全屏(实际的全屏不仅仅是窗口)。我不太明白,但根据microsoft,似乎具有2016版服务器技术预览的计算机可以将控制台全屏(热键:ALT + ENTER)。

我要问的是:在所有Windows版本(Windows XP之后的ofc)的2016 服务器技术预览之前,你能否拥有一个使控制台应用程序真正全屏显示的功能?

注意:我家里有一些笔记本电脑,包括WIN 10,WIN 8.1和WIN 7,我可以测试它是否真的有用。

我尝试了什么:

1

/*The ALT+ENTER method*/
/*It worked on my WIN10 laptop, failed on the other ones.*/
/*On the WIN7 it also said "Console does not support fullscreen mode".*/
void fullscreen()
{
    keybd_event(VK_MENU,0x38,0,0);
    keybd_event(VK_RETURN,0x1c,0,0);
    keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
    keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
}

2

/*Same results as the one above.*/
/*On the WIN8.1 GetLastError() returns 87 (aka invalid parameter)*/
void fullscreen()
{
    SetConsoleDisplayMode(GetStdHandle(STD_OUTPUT_HANDLE),CONSOLE_FULLSCREEN_MODE,NULL);
}

如果有测试机器是否具有 2016服务器技术预览的方法,请告诉我。感谢。

1 个答案:

答案 0 :(得分:0)

作为批处理程序员,我会说如果你使用Windows,你必须学习一些提示。 为了避免您的问题,您可以使用函数系统,该函数系统使用添加到您的c ++代码中的实际批处理代码串:

你应该使用

    outfile.open(outfilename.str()); /* WRITING TO FILE */
    outfile.width(9);
    outfile.precision(5);
    outfile.setf(ios_base::fixed,ios_base::floatfield);
    outfile << "#   E_Fermi (eV) : " << efermi << "   Number of points in energy grid : " << nen << "   Smearing HWHM (eV): " << hwhm << "   Units: rho*Ang^3/eV " << endl;
    outfile << "#Energy\tTot\ts tot\tp tot\td tot\tp_x\tp_y\tp_z\td_xy\td_yz\td_z2\td_xz\td_x2-y2" << endl;
    for (int e=0;e<nen;e++) 
    {
        outfile << plote[e] << "\t" << plotdostot[e] << "\t" << plotdoss[e] << "\t" << plotdosp[e] << "\t" << plotdosd[e];
        outfile << "\t" << plotdospx[e] << "\t" << plotdospy[e] << "\t" << plotdospz[e];
        outfile << "\t" << plotdosdxy[e] << "\t" << plotdosdyz[e] << "\t" << plotdosdz2[e] << "\t" << plotdosdxz[e] << "\t" << plotdosdx2y2[e] << endl;
    }
    outfile.close();