Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7734131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:10:24+00:00 2026-06-01T07:10:24+00:00

When I compile and run a simple Win32 GUI program in MinGW+MSys with command

  • 0

When I compile and run a simple Win32 GUI program in MinGW+MSys with command line:

$ g++ main.cpp -o app -std=c++0x

$ ./app

only a dialog box shows. But when I put this program into Code::Blocks IDE and compile it, it always results in a black console box with the dialog. Adding -mwindows in link options no effect.

main.cpp:

#include <windows.h>
int WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
    MessageBox(0,"Hello, Windows","MinGW Test Program",MB_OK);
    return 0;
}

How can I get rid of the console box?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:10:25+00:00Added an answer on June 1, 2026 at 7:10 am

    Put it in a project, and in the project settings there’s an option to not have a console window.

    If you can’t be bothered to have it in a project, a call to ShowWindow (GetConsoleWindow(), SW_HIDE); will make it flash on the screen and then disappear. Note that you must #define _WIN32_WINNT as 0x0500 or greater before including windows.h to have access to GetConsoleWindow(). I’ll come back in a bit with a specific location to disable it.

    //hide console window at start
    #define _WIN32_WINNT 0x0501 //this is for XP
    #include <windows.h>
    
    int main()
    {
        ShowWindow (GetConsoleWindow(), SW_HIDE);
        //rest of program here
    }
    

    EDIT:
    Found it, here’s how to not have a console window:

    1. Click Project on the CodeBlocks menu.
    2. Click Properties.
    3. Click the second tab, Build Targets.
    4. On the right, where it says Type: Console application, change it to GUI application.
    5. Rebuild the project.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just trying to compile and run a very simple test program, but
I am trying to compile and run a simple java class within eclipse. The
How can I check and conditionally only compile / run code if iOS5 is
How do I compile and run a program in Java on my mac? I'm
I am running a very simple C++ program: #include <list> #include <vector> int main(int
I am trying to compile and run a simple tutorial for an Objective C
I am trying to run a simple shell command that runs and returns text
i just tried to compile and run a simple example which was found on
Trying to run a simple Hello World C++ program on Eclipse (Galileo) CDT plugin
I'm struggling to compile and run a program on Mac OS X, which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.