Adding a string into some text in a window

Hi. I'm Sure what I'm trying to do is simple, and the answer is staring me in the face, but after hours of googling around, my brain has turned to mush. I want a Simple this is how you do it. I'm sure I'm googling the wrong question to start with.

Take the following code snippet (out of context):

1
2
LPSTR Version = "1.0 Alpha";
MessageBoxA(hwnd, Version , "ABOUT", MB_OK | MB_ICONINFORMATION);


This works fine. I get the box up, that says 1.0 Alpha, with the ok button

What I want is to append text to the box, to say somthing like 1.0 Alpha By Dave, without just editing the string.

what I was hoping for was somthing like ( I know the syntax is incorrect, but im just trying to illustrate what I'm trying to do):

1
2
LPSTR Version = "1.0 Alpha";
MessageBoxA(hwnd, Version + " By Dave" , "ABOUT", MB_OK | MB_ICONINFORMATION);


Thankyou very much for any help.

the

Version + " By Dave" is the bit i cant seem to figure

Dumb question, I know

Regards, Dave
MessageBoxA(hwnd, Version + " By Dave" , "ABOUT", MB_OK | MB_ICONINFORMATION);

Should work the way you have it. If not, try to cast the string like so:
MessageBoxA(hwnd, Version + (LPSTR)" By Dave" , "ABOUT", MB_OK | MB_ICONINFORMATION);

I haven't tested this, and I don't have much experience with unicode, so apologies if I gave you wrong information.
I Apologize.

I didn't even mention the actual description of the problem

The tool-tip error message is "Error: Expression must have Integral or Enum Type"


Thankyou, Balrog for the reply.

MessageBoxA(hwnd, Version + (LPSTR)" By Dave" , "ABOUT", MB_OK | MB_ICONINFORMATION);

Does not work. Same issue
just realized somthing.

LPSTR Version = "1.0 Alpha";

is a pointer to a string (DUH), so by doing:

Version + " By Dave"

The compiler is thinking im trying to do arithmetic on the pointer, which OBVIOUSLY isn't going to Work.

I want to display two strings side by side.
very similar to

std::cout << Version << " By Dave \n"

Am I on the right track?
Last edited on
1
2
3
std::string message(Version) ;
message += " By Dave" ;
MessageBoxA(hwnd, message.c_str() , "ABOUT", MB_OK | MB_ICONINFORMATION);
Wonderful.


1
2
3
std::string message(Version) ;
message += " By Dave" ;
MessageBoxA(hwnd, message.c_str() , "ABOUT", MB_OK | MB_ICONINFORMATION);


Worked
Thankyou..
Topic archived. No new replies allowed.