Q74800: INFO: Working Around the STRINGTABLE 255 Character Limit
Article: Q74800
Product(s): Microsoft Windows Software Development Kit
Version(s): WINDOWS:3.1
Operating System(s):
Keyword(s): kb16bitonly kbResource kbSDKPlatform kbString
Last Modified: 10-JUN-1999
3.00 3.10
WINDOWS
kbprg
-------------------------------------------------------------------------------
The information in this article applies to:
- Microsoft Windows Software Development Kit (SDK) 3.1
-------------------------------------------------------------------------------
SUMMARY
=======
Windows STRINGTABLE resources are limited to 255 characters per string. However,
it is possible to work with longer strings using the technique described in this
article.
MORE INFORMATION
================
The following function, MyLoadString, will allow strings longer than 255
characters to be loaded. Using the exclamation mark ("!") to indicate that a
particular string is part of a longer whole is not required; any character that
does not otherwise start a string may be used for this purpose. The string IDs
used for pieces of the same string must be consecutive.
MyLoadString(HANDLE hInst, WORD wID, LPSTR szBuf)
{
int i, j;
char szLoadedString[256]; // temporary buffer
*szBuf = 0;
do
{
LoadString(hInst, wID, szLoadedString, 255);
if ('!' == *szLoadedString)
{
lstrcat(szBuf, (szLoadedString + 1));
wID++;
}
else
lstrcat(szBuf, szLoadedString);
}
while ('!' == *szLoadedString);
return lstrlen(szBuf);
}
The RC file will take on a form resembling the following:
STRINGTABLE
BEGIN
100, "!This is the first part of the string to be loaded,"
101, "!this is the second part, "
102, "and this is the third"
END
Additional query words: 3.00 3.10
======================================================================
Keywords : kb16bitonly kbResource kbSDKPlatform kbString
Technology : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWinSDKSearch kbWinSDK310
Version : WINDOWS:3.1
Issue type : kbinfo
=============================================================================
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.