Results 1 to 5 of 5

Thread: C++ project running in something other than cmd

  1. #1

    Thread Starter
    Member
    Join Date
    May 2007
    Posts
    48

    C++ project running in something other than cmd

    #include <iostream>

    using namespace std;

    int main()
    {
    int carrots;

    carrots = 25;
    cout << "I have " << carrots << " carrots." << endl;

    carrots = carrots - 1;
    cout << "Crunch crunch, i now have " << carrots << " carrots." << endl;

    return 0;
    }

    When ii compile and run this code with microsoft visual c++ it opens in command prompt all the time with anything. Ive seen applications in C++ in a fully user friendly format like a VB app.. WTH is it always opening in cmd?

    help is mre than appreciated
    thanks

  2. #2
    Lively Member
    Join Date
    Feb 2006
    Posts
    125

    Re: C++ project running in something other than cmd

    That's what that program was designed to do.
    build an interface for it!
    What exactly is your question?

  3. #3
    Junior Member MushroomSamba's Avatar
    Join Date
    Sep 2008
    Location
    In my room.
    Posts
    19

    Re: C++ project running in something other than cmd

    Quote Originally Posted by bobdabilder
    That's what that program was designed to do.
    build an interface for it!
    What exactly is your question?
    He wants to know how to give it a window and such, instead of the black monolith we know as the command window.

    I won't show you how to create a window, there's tons and tons of tutorials out there for that. Just google "CreateWindow C++ Example" or something.

    BUT: For getting rid of the command window, all you have to do is use WinMain instead of main. It looks like this:

    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);

    Where:
    hInstance: A handle to the program this function's in.
    hPrevInstance: A handle to the last copy of this program that was opened.
    lpCmdLine: The command line that was called with the program. For example, if the program was called like typing "C:\Program.Exe /1", "/1" would be the command line.
    nCmdShow: This is a 'suggestion' of sorts from windows as to how the programs primary window should be opened, as in maximized, minimized, whatever.

  4. #4
    Lively Member
    Join Date
    Feb 2006
    Posts
    125

    Re: C++ project running in something other than cmd

    building a windows form application is easy in vs2005 etc. or you can go the api route.

  5. #5
    Junior Member MushroomSamba's Avatar
    Join Date
    Sep 2008
    Location
    In my room.
    Posts
    19

    Re: C++ project running in something other than cmd

    Quote Originally Posted by bobdabilder
    building a windows form application is easy in vs2005 etc. or you can go the api route.
    I hate having the program do anything behind my back, tis why I switched to C++. API all the way, babeh.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width