C++ string in a windows function
If I use GetWindowText, I use it as follows:
Easy, but let's say I want to do something with the string, to easly work with it, I put it in a C++ string, I prefer to work with C++ strings.
char WindowCaption [ 1024 ];
GetWindowText ( Window, WindowCaption, 1024 );
Done, only the thing is I need to use two strings.
std :: string Caption = WindowCaption;
I am able to directly use a C++ string in the following code:
As you can see I used the c_str() function, but when I try the following, the c_str() function wont help:
MessageBox ( Window, "Message Box Text", Caption.c_str(), MB_OK );
It will give me a compile error so I tried a lot of things but they all didn't work.
std :: string WindowCaption;
GetWindowText ( Window, WindowCaption.c_str(), 1024 );
I actually have this problem quite long but I never bothered about it, I always just used two strings.
Only now I really would like to only use one C++ string with GetWindowText, can someone help me how to that?
Thank you, Yuri.