Yes, assuming this is C you would use sprintf or something equivalent to format the points into your string:
char buffer[100];
sprintf ( buffer, "Total points: %u", points );
MessageBox(hwnd, "You have bla bla", buffer, MB_OK);
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
ostringstream stm ;
stm << "Total points " << points ;
MessageBox(hwnd, "You have bla bla", stm.str().c_str(), MB_OK);
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287
No. MessageBox takes a string. If you want to use a variable, it has to be contained in a string. That should be a pretty obvious restriction given the documentation on MessageBox.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
I guess no:
int MessageBox(
HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType
);
lpText [in] Pointer to a null-terminated string that contains the message to be displayed.
lpCaption [in] Pointer to a null-terminated string that contains the dialog box title. If this parameter is NULL, the default title Error is used.
Beaten..
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Use the options suggested in posts 2 and 3.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
>and also..I dont think sprintf would help here
Why not? It does exactly what you want. You can also use stringstream like what's-his-name suggested if you're writing C++ code. Or you can do any number of things to format a number into a string, but they're all fundamentally the same operation.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Yes, assuming this is C you would use sprintf or something equivalent to format the points into your string:
char buffer[100];
sprintf ( buffer, "Total points: %u", points );
MessageBox(hwnd, "You have bla bla", buffer, MB_OK);
Hello Team:
I would like to create a "message box" to print out multiple lines of information on the screen from one of our applications.
My question is what is the "hwnd" operand and how do I define or initialize it? I believe the MB_OK relates to the generation of the message box itself.
Where else can I find out about the creation and use of message boxes using C?
Thanks in Advance....!!!
kxh29
Junior Poster in Training
56 posts since Apr 2007
Reputation Points: 10
Solved Threads: 1
According to MS, hwnd is a Handle to the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.
This thread is getting a little old by now. You'll get better result if you post in a new thread of your own.
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218