I created a simple Win32 app and made it form driven and then added 2 buttons named Button1 and Button2.
Then I did something simple like this for their functionality:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
void CMessageTextTest3Dlg::OnBnClickedButton1()
{
wchar_t Title2k[2000] = {'\0'};
wchar_t String2k[2000] = {'\0'};
wmemset(Title2k, 69, 1999); // gonna party like it's...
wmemset(String2k, 69, 1999);
Title2k[1999] = '\0';
String2k[1999] = '\0';
MessageBox(String2k, Title2k);
}
void CMessageTextTest3Dlg::OnBnClickedButton2()
{
wchar_t Title4k[4000] = {'\0'};
wchar_t String4k[4000] = {'\0'};
wmemset(Title4k, 69, 3999);
wmemset(String4k, 69, 3999);
Title4k[3999] = '\0';
String4k[3999] = '\0';
MessageBox(String4k, Title4k);
}
|
Worked just fine. So, there isn't any limit in the native C++, native Win32 world that I could find, though I didn't push it. I'm sure there's some practical limit. I mean, at some point you run out of memory.
As for the rest of your questions:
1) Heading string too long displays as "blah blah bla..."
2) All c-style strings must end in '\0'. You may SOMETIMES get by with not doing so
completely by accident but never count on it.
3) See above.
4) I didn't test this, but you can do so using the test code I gave you above. If just '\n' doesn't display properly, you may have to look for it and add a '\r', as well.
5) Under Windows they'll just display crap, but yes, they should be fine to print. That said, TEST, TEST, TEST!
6) Yes, the above test code could have as easily initialized to a 2000 line string of 'E's in quotes with no \0 (it's implied under Windows).
7) The note about overlapping strings is when you're trying to do an in place reduction in string size or trying to do funky stuff like "borrow" from one string to fill another. You should **NEVER** do this! Always make every string have it's own buffer unless you are FORCED to do otherwise. And, if you are forced to do so seriously consider a rewrite/redesign. The only time I can think of that this makes SOME sense is if there is a resource issue (memory or performance).
Xen