隐藏终端程序窗口

Posted SurfUniverse

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了隐藏终端程序窗口相关的知识,希望对你有一定的参考价值。

#include <iostream>
using namespace std;

// I‘m using Vista ATM (it‘s evil), but GCC comes assuming the worst.
// If you haven‘t patched your compiler to agree with the actual version
// of the Windows OS, then you will need to make sure you do it like this.
//
#if       _WIN32_WINNT < 0x0500
  #undef  _WIN32_WINNT
  #define _WIN32_WINNT   0x0500
#endif
#include <windows.h>

// Here‘s some fun timer stuff for the user.
// (Notice how he won‘t see it work when the
//  console is hidden, but it will still work.)
void timeout()
  {
  for (int cntr = 3; cntr > 0; cntr--)
    {
    cout << "\r" << cntr << flush;
    Sleep( 1000 );
    }
  cout << "\r" << flush;
  }

// Demonstrate some fun stuff.
// Notice how hiding the console window causes it to disappear from
// the Windows task bar. If you only want to make it minimize, use
// SW_MINIMIZE instead of SW_HIDE.
//
int main()
  {
  cout << "Preparing to hide the console window\n";
  timeout();
  ShowWindow( GetConsoleWindow(), SW_HIDE );

  cout << "Preparing to show the console window\n";
  timeout();
  ShowWindow( GetConsoleWindow(), SW_RESTORE );

  cout << "All done!\n";
  return 0;
  }

copy from: http://www.cplusplus.com/forum/beginner/12001/

以上是关于隐藏终端程序窗口的主要内容,如果未能解决你的问题,请参考以下文章

JavaFX自定义窗口标题栏

关于VSCode--1.36.1版本如何隐藏调试时出现的终端窗口

JavaFX窗口拖动

在android中显示隐藏片段

C++ 解释器/控制台/片段编译器

Python学习总结