Re: FormatMessage LoadString from string table
On 14 Sep., 14:29, Goran Pusic <gor...@cse-semaphore.com> wrote:
On Sep 14, 2:24 pm, mfc <mfcp...@googlemail.com> wrote:
Then call raw ::FormatMessage passing sa.GetData as the string count =
parameter; but if so,
your formatting string MUST have %1 through %40 defined.
CStringArray strArray; //values already included
CString str ("%1, %2, %3, %4");
str.FormatMessage(str, strArray.GetAt(0), strArray.GetAt(1)....);
but how can I obtain str.GetData() to pass the strings to CString str
by using FormatMessage()? At the moment it is working but if you have
40 items it is not very clean or readable....
Note that you are tying number of %1/2/3/4 format specifiers with the
size of the array. That's IMO a bigger problem than readability.
BTW, if you purpose is to "translate" parts of the text by replacing
stuff, you might want to consider simply having separate completely
"translated" texts. You also might want to use a tool to create them.
Don't push a good idea to far, that often turns a good idea into a bad
one ;-).
Goran.
I think you`re right, FormatMessage is not the right purpose here.
Because it seems there is no possibility using one function where I
can add x-string-items by FormatMessage to the specific string. X-
string-items means that the number of strings adding via FormatMessage
could be different from time to time. I`ve several strings with
different number of format specifiers (%1, %2 and so on)...
void AddItemsToStr(UINT number, CStringList& strList)
{
CString str;
str.FormatMessage(str, strList.GetAt(0).......,
strList.GetAt(number));
}