Problem with AfxFormatStrings
-
Hi all, i am facing problem with AfxFormatString, as the the Parameters it will take from only "%1 to %9" as Arguments for subtitution from Resource String. Please help me to Append beyond that, I Mean after 9 th Parameter. code: ----- Resource String : String ID --------- IDS_GTD_WIZ_SET_STANDARD_CONTROLLER Caption ------- "It is necessary to set one or more equipment other than %1, %2,\n%3, %4, %5, %6, %7, %8,\n%9 and %10 to Communication ettings." Here i am trying to Subtitue this %1,%2,%3,%4,%5,%6,%7.... upto %9 but after subtituion of %10 i am not reflecting that. CString lC_Str_DriverArray[10]; UINT lui_Index = 0; lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_BARCODE); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZARD_REFID); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_GATEWAY); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_ETHERNETDOWNLOAD); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_PRINTER); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_VIDEORGB); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_RGBOUTPUT); //Extended Step Addition lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_EXTENDED_MEMORYCARD); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_SOUND_OP_UNIT); lC_Str_DriverArray[lui_Index].LoadString(IDS_GTD_WIZ_EXTERNAL_IO_UNIT); //Load error message AfxFormatStrings(lC_Str_Msg,IDS_GTD_WIZ_SET_STANDARD_CONTROLLER,(LPCTSTR*)lC_Str_DriverArray,10); Here after 9th String i am getting Problem. in %10 it is subtituting as %1 what to do. please help me out.
Uday kiran
-
Hi all, i am facing problem with AfxFormatString, as the the Parameters it will take from only "%1 to %9" as Arguments for subtitution from Resource String. Please help me to Append beyond that, I Mean after 9 th Parameter. code: ----- Resource String : String ID --------- IDS_GTD_WIZ_SET_STANDARD_CONTROLLER Caption ------- "It is necessary to set one or more equipment other than %1, %2,\n%3, %4, %5, %6, %7, %8,\n%9 and %10 to Communication ettings." Here i am trying to Subtitue this %1,%2,%3,%4,%5,%6,%7.... upto %9 but after subtituion of %10 i am not reflecting that. CString lC_Str_DriverArray[10]; UINT lui_Index = 0; lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_BARCODE); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZARD_REFID); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_GATEWAY); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_ETHERNETDOWNLOAD); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_PRINTER); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_VIDEORGB); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_CONTROLLER_RGBOUTPUT); //Extended Step Addition lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_EXTENDED_MEMORYCARD); lC_Str_DriverArray[lui_Index++].LoadString(IDS_GTD_WIZ_SOUND_OP_UNIT); lC_Str_DriverArray[lui_Index].LoadString(IDS_GTD_WIZ_EXTERNAL_IO_UNIT); //Load error message AfxFormatStrings(lC_Str_Msg,IDS_GTD_WIZ_SET_STANDARD_CONTROLLER,(LPCTSTR*)lC_Str_DriverArray,10); Here after 9th String i am getting Problem. in %10 it is subtituting as %1 what to do. please help me out.
Uday kiran
I would advise you to use boost::format[^] Boost is a library of very high standards. So high, parts of it will find its way into the upcoming C++ standard. It is completely free. Another possibility is building your message in a std::ostringstream, and get it from there.
std::ostringstream stream;
CString tmp;
stream << _T("It is necessary to set one or more equipment other than ");
stream << (LPCTSTR)tmp.LoadString(IDS_GTD_WIZ_CONTROLLER_BARCODE);
...
std::string s = stream.str();
CString s1 = s.c_str();
Failure is not an option - it's built right in.
-
I would advise you to use boost::format[^] Boost is a library of very high standards. So high, parts of it will find its way into the upcoming C++ standard. It is completely free. Another possibility is building your message in a std::ostringstream, and get it from there.
std::ostringstream stream;
CString tmp;
stream << _T("It is necessary to set one or more equipment other than ");
stream << (LPCTSTR)tmp.LoadString(IDS_GTD_WIZ_CONTROLLER_BARCODE);
...
std::string s = stream.str();
CString s1 = s.c_str();
Failure is not an option - it's built right in.
hi jhwurmbach, I Understand your answer. But the Code T("It is necessary to set one or more equipment other than "); must not be hard coded and this is the String Table of the Resource with %1 %2 %3 ..... and Dynamically it must subtitute accordingly. please let me know any solution for this.
Uday kiran
-
hi jhwurmbach, I Understand your answer. But the Code T("It is necessary to set one or more equipment other than "); must not be hard coded and this is the String Table of the Resource with %1 %2 %3 ..... and Dynamically it must subtitute accordingly. please let me know any solution for this.
Uday kiran
OK. I see. You got the text with the %1-replace markers inside and can not change it. How stupid! You could have a regex[^] exchanging all '%digit' by '%digit%' and use something like this
cout << boost::format("writing %1%, x=%2% : %3%-th try") % "toto" % 40.23 % 50;
// prints "writing toto, x=40.230 : 50-th try"(example from the boost-page) Ok. This idea comes out of desperation.
Failure is not an option - it's built right in.