System: Intel, Windows XP Pro, SP2
IDE: VC++ 6.0
Problem: *Very* simple program to create a MessageBox only ever displays the first character of the given string.
I checked the spec for the MessageBox function and I believe I am adhering to it. I have also done a search for this issue, but have come up empty handed. Perhaps my search parameters were at fault ...
[CODE=CCode]#include <windows.h> // added to make MessageBox work (esp w/MB_<code>s)
#include <string> // added to make std wstrings work
int main( int argc, char* argv[] )
{
std::wstring content = L"If this works, it will be a miracle.";
std::wstring title = L"This is a Message Box";
// Generates box with only the first characters of each string - why?...
MessageBox(0, (LPCTSTR)conten t.c_str(), (LPCTSTR)title. c_str(), MB_OK);
// Title: "Error" displays as expected, content still only displays first letter ...
MessageBox(0, (LPCTSTR)conten t.c_str(), 0, MB_OK);
// Title: "Error" displays as expected, content still only displays first letter
MessageBox(0, (LPCTSTR)L"smal l", 0, MB_OK);
return( 0 );
}[/CODE]
More info:
I'm working with this silly-simple program in an attempt to debug a much more complicated issue in a different program. I am starting with as little as possible and trying to get it to work so I can confirm the minimum requirements to run MessageBox successfully.
I want to steer clear of using the conversion functions for other reasons and in this case I don't think the (LPCTSTR) should be doing bad things -- of course other opinions are welcome especially if they offer insight into the current issue.
Thank you for taking a look at this, and ahead of time for any advice you might have, even if you can just point me to a new reference.
IDE: VC++ 6.0
Problem: *Very* simple program to create a MessageBox only ever displays the first character of the given string.
I checked the spec for the MessageBox function and I believe I am adhering to it. I have also done a search for this issue, but have come up empty handed. Perhaps my search parameters were at fault ...
[CODE=CCode]#include <windows.h> // added to make MessageBox work (esp w/MB_<code>s)
#include <string> // added to make std wstrings work
int main( int argc, char* argv[] )
{
std::wstring content = L"If this works, it will be a miracle.";
std::wstring title = L"This is a Message Box";
// Generates box with only the first characters of each string - why?...
MessageBox(0, (LPCTSTR)conten t.c_str(), (LPCTSTR)title. c_str(), MB_OK);
// Title: "Error" displays as expected, content still only displays first letter ...
MessageBox(0, (LPCTSTR)conten t.c_str(), 0, MB_OK);
// Title: "Error" displays as expected, content still only displays first letter
MessageBox(0, (LPCTSTR)L"smal l", 0, MB_OK);
return( 0 );
}[/CODE]
More info:
I'm working with this silly-simple program in an attempt to debug a much more complicated issue in a different program. I am starting with as little as possible and trying to get it to work so I can confirm the minimum requirements to run MessageBox successfully.
I want to steer clear of using the conversion functions for other reasons and in this case I don't think the (LPCTSTR) should be doing bad things -- of course other opinions are welcome especially if they offer insight into the current issue.
Thank you for taking a look at this, and ahead of time for any advice you might have, even if you can just point me to a new reference.
Comment