|
-
Sep 5th, 2008, 02:06 AM
#1
Thread Starter
Member
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
-
Sep 5th, 2008, 05:07 PM
#2
Lively Member
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?
-
Sep 20th, 2008, 10:29 AM
#3
Junior Member
Re: C++ project running in something other than cmd
 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.
-
Sep 20th, 2008, 10:37 AM
#4
Lively Member
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.
-
Sep 20th, 2008, 10:39 AM
#5
Junior Member
Re: C++ project running in something other than cmd
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|