Reputation: 816
I have tried to make a simple MessageBox
using this code:
#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
.
Is there a way to get rid of this console window?
Upvotes: 2
Views: 2363
Reputation: 1
Here you 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);
}
Upvotes: 0
Reputation: 45239
Yes, compile for the "windows" subsystem. Here are instructions for performing this task on multiple IDEs.
Upvotes: 7
Reputation: 129754
WinMain
— see any introduction to Windows programming).Upvotes: 1