Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

messagebox & Input box question?

Status
Not open for further replies.

splinter

Technical User
May 3, 2002
2
GB
hello,
I would like to know more about this,when use in win32 console.

Messagebox(NULL,"Hello:","Title,2);

1. That displays a message box.How do I control the YEs/No
option. Would i have to use if/else? And can you give me a short example code so I can see how it works?

2. How would I out something using the message box. For
example, let say I did 2+2=4,; I want to display the output 4 using the messagebox. Can you please show an example code on how to set it up.

3. Since we can use messagebox on win32 console, is there
an InputBox code like that of VB, that can be use in win32 console? If yes please show me how its declare.

thankyou in advance.
 
#define WIN32_LEAN_AND_MEAN
#include <iostream>
#include <windows.h>

int main()
{

int iResponse = 0;
int iTemp = 0;
char sString[50];

iResponse = MessageBox( NULL,&quot;Choose Yes or No&quot;,
&quot;MessageBox&quot;,
MB_YESNO | MB_ICONQUESTION );

if ( iResponse == IDYES )
MessageBox( NULL,&quot;YOU SELECTED YES&quot;,
&quot;MessageBox&quot;,MB_OK );
else
MessageBox( NULL,&quot;YOU SELECTED NO&quot;,
&quot;MessageBox&quot;,MB_OK );

std::cout << &quot;Enter a number please: &quot;;
std::cin >> iTemp;

sprintf( sString,&quot;You entered the # %d&quot;,iTemp );
MessageBox( NULL,sString,&quot;MessageBox&quot;,MB_OK );

return 0;

}

I don't believe there is any InputBox() function in VC++ that is equivalent to VB's. It would of course be trivial to implement an InputBox() function if you were to incorperate it into a windowed app. Mike L.G.
mlg400@blazemail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top