[英]How to get rid of the console window
I have tried to make a simple MessageBox
using this code:我尝试使用以下代码制作一个简单的
MessageBox
:
#include <windows.h>
int main() {
MessageBox(NULL, "Hello", "Message Box", MB_OKCANCEL);
}
But upon building this in the Dev-C++ IDE with the MinGW toolchain, I get a console window popping up behind the MessageBox
.但是在使用 MinGW 工具链在 Dev-C++ IDE 中构建它时,我在
MessageBox
后面弹出了一个控制台 window 。
Is there a way to get rid of this console window?有没有办法摆脱这个控制台 window?
Yes, compile for the "windows" subsystem. 是的,编译“windows”子系统。 Here are instructions for performing this task on multiple IDEs .
以下是在多个IDE上执行此任务的说明 。
WinMain
— see any introduction to Windows programming). WinMain
- 请参阅Windows编程的任何介绍)。 Here you go给你 go
#include <Windows.h>
int main() {
HWND hwnd;
AllocConsole();
hwnd = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(hwnd, 0);
MessageBox(NULL, "Hello", "Message Box", MB_OKCANCEL);
ShowWindow(hwnd, 0);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.