Re: FormatMessage LoadString from string table



In re-reading your question, and still trying to figure out what you are asking...

If you want to concatenate a series of strings (separated by spaces, for example) the code
is

CString sep;
CString result;
for(...)
{
CString s;
s.LoadString(IDS_STRING_START + i);
result += sep;
result += s;
sep = _T(" ");
}

Pretty basic programming here.
joe

On Mon, 13 Sep 2010 06:35:47 -0700 (PDT), mfc <mfcprog@xxxxxxxxxxxxxx> wrote:

Hi,

do you know if there`s a simple / fast solution to add several strings
from the string-table to one CString using FormatMessage?

CString test ("%1%, %2% some other comments %3% and %4%");
CString test2("");
for(int i=0; i<MAX_NBR_OF_STR; i++)
{
test2.LoadString(IDS_TEST_START + i);

test.FormatMessage(test2);
}
I know this solution will not work - but maybe it is possible with a
few hints.

I don`t want to use 40 CStrings test2[1-40] to load all strings from
the string-table and add them by using FormatMessage.

best regards
Hans
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Starting from the beginning
    ... From what I see, you are mixing code for "generic" strings and functions, which expand to ASCII or UNICODE strings and methods depending on the settings, with ASCII-only methods. ... You are also comparing characters of CipStr (I assume it is declared as CString, since I see no declaration for it) with bytes which would not be right in a UNICODE build. ... /CIP3PreviewImageHeight 726 def ...
    (microsoft.public.vc.mfc)
  • Re: Stack getting corrupted
    ... I am still getting some junk in the strings, ... strncpy(sReturn, strData, dwValSize); ... char strData; ... Can I avoid using MFC CString or std::string types here? ...
    (microsoft.public.vc.language)
  • Re: CString changing an independant int
    ... I simply had two strings mixed up. ... If you are in the middle of doing that assignment, ... the edit control, the edit control will generate an EN_CHANGE/EN_UPDATE set of ... thought it would be impossible with a CString... ...
    (microsoft.public.vc.mfc)
  • Re: CMAP under vs2005+
    ... I used for many years as a way to map case insensitive key strings to ... Note that you can mix std::map with CString class. ... The custom key comparer is responsible to do the case *in*sensitive ... bool operator(const CString & left, ...
    (microsoft.public.vc.language)
  • Re: CMAP under vs2005+
    ... I used for many years as a way to map case insensitive key strings to ... So, if you want a case insensitive map from string to string, using CString ... The custom key comparer is responsible to do the case *in*sensitive ... bool operator(const CString & left, ...
    (microsoft.public.vc.language)