Jump to content
  • Advertisement
Sign in to follow this  
shadowfire36

can you put a message box through C++ ?

This topic is 3788 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i was wonder if any one knew if its possible to add a input message box and code it through C++??? i know how to do it in VB , but i didnt know if you could use it in C++.

Share this post


Link to post
Share on other sites
Advertisement
Not sure if I completely understand your question, but C++ doesn't have that functionality, so you'll have to use an external library.

Share this post


Link to post
Share on other sites
A quick guess, but I reckon you'd have to design the box yourself in the IDE (or code it by hand) and have it return the contents of the text box.

Share this post


Link to post
Share on other sites
You can do it with the Win32 API. How you do it depends on what exactly you're trying to do - what exactly "input message box" means.

Share this post


Link to post
Share on other sites
Assuming you mean something like this, it might be possible in MFC, but MFC generally gives people headaches. C++ and MFC allow multiple inheritance, which can be a pain in the ass, according some programmers. It is something to look into, however, and you might enjoy it. Good luck :)

Share this post


Link to post
Share on other sites
Not even Visual Basic has this capability when stripped to its bare language without libraries. If you're talking about something like "MessageBox.Show" using the .NET platform, you're going to have to look into Win32 API or Managed C++.

Share this post


Link to post
Share on other sites
OK... here is my code

it already has a menu but i would prefer if it had a messagebox . is there somewhere i may add it to the code?

what i want is exactly anothrguitarist showed in his link he showed




#include <iostream>

using namespace std;

const int A_QUANTITY = 10; //amount of #s entered for choice A
const int B_SENTINAL = -99; //sentinal used to end choice B

int main()
{
bool again = true; //used to control main choice loop
int choice; //stores the choice made
int bigger; //stores current biggest #
int smaller; //stores current smallest #
int temp; //stores next number for comparison
int i; //controls the For loop

while (again)
{
//displays instructions for main options
cout << "What would you like to do?" << endl;
cout << "(enter the letter of your choice)" << endl;
cout << "1 - For loop" << endl;
cout << "2 - Do loop"<< endl;
cout << "3 - Quit this program." << endl;

//obtains choice and ignores the remaining input
cin >> choice;

if (choice == 1)
{
for( i = 0; i < 10; i++)
cout << "i = " << i << endl;
cout << "now we will do it backwards" << endl;

for (i = 10; i>=0; i--)
{// when a for loop has more than 1 line, you must have {} around it
cout <<" i = ";
cout << i << endl;
}// end of 2nd for loop
}// end of if
else if (choice == 2)
{
i = 0;
do
{
cout << "i = " << i << endl;
i++;
} while (i < 10);
}//end of else
else // not 1 or 2
return 0;
}// end of while loop

}// end of main












Share this post


Link to post
Share on other sites
Quote:
Original post by shadowfire36
is there somewhere i may add it to the code?
Simple answer: If you're learning C++, no. Adding a dialog like that involves a huge amount of Win32 code (about 2 or 3 hundred lines), and I doubt you'd understand any of it.

We can give you code to give a box like that, but you probably won't understand how it works, and it involves using Win32 (as I said), which means your code won't run on non-Windows machines (If that's a problem). It also requires that you have the platform SDK installed (And setting that up depends on your compiler).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!