question

FrankHeimes-6803 avatar image
0 Votes"
FrankHeimes-6803 asked TianyuSun-MSFT commented

How to enter cyrillic text in Visual Studio resource editor for a drop down list?

I need to translate an MFC application to Russian.
The resource file is set up; i.e. it is stored in Unicode format.
All resources and strings show up correctly, with the exception of the drop down list entries.
These are stored as hexadecimal values in the DLGINIT section of the RC file.
The resource editor displays the drop down values correctly, but the dialog does not.
Is there a way to get this right using the resource editor? I know I can work around this in the C++ code.
See screenshot:
46150-resourceeditorrussian.png


c++vs-general
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If I try to commit entering Cyrillic characters in the Data property (with a UK English OS), Visual Studio shows this error:

The property was not set due to a conversion error. Please use characters that can be converted to MBCS in the resource's language.


So, I suspect your code page supports those character conversions, so you don't get that error, but there's something else that's not playing ball.

I suggest that you submit a bug report to MS about this (VS really ought to support Unicode by now) using the "Report a Problem" facility. Please post a link to your bug report back here if you do so that others can follow/vote on it.

For now, your solution seems to be to write the values into the combo at run-time.

2 Votes 2 ·

A quick internet search indicates that the DLGINIT resource does not support unicode strings. Apparently, this issue has existed for a long time.

2 Votes 2 ·

Yes, this was my finding, too. I doubt that Microsoft will invest any more work into this ancient resource management system.

0 Votes 0 ·

I agree that it's unlikely, but you never know, and if we don't ask for it, we certainly won't get it.

0 Votes 0 ·

Hi @FrankHeimes-6803, thank you for taking time to post this issue in Microsoft Q&A forum. I agree with David and RLWA32, I suggest you can try to directly report this issue to Visual Studio Product Team in our Developer Community(in Visual Studio, select Help > Send Feedback > Report a Problem…).

Besides, as David mentioned above, you can share the link here(if you report this issue in Developer Community), and other forum members, include me, who are interested in this issue or meet similar issues will go to vote for this thread.


0 Votes 0 ·

1 Answer

SM-4238 avatar image
1 Vote"
SM-4238 answered FrankHeimes-6803 commented

The DLGINIT section is read in here (C:\Program Files (x86)\Microsoft Visual Studio....\atlmfc\src\mfc\wincore2.cpp)

 BOOL CWnd::ExecuteDlgInit(LPVOID lpResource)
 {
 ....
     if (nMsg == LB_ADDSTRING || nMsg == CB_ADDSTRING)
     {
         // List/Combobox returns -1 for error
         if (::SendDlgItemMessageA(m_hWnd, nIDC, nMsg, 0, (LPARAM) lpnRes) == -1)
             bSuccess = FALSE;
     }
 ....
 }

If you are willing to copy some MFC source code, into your dialog class you could modify the above function as such:

         if (nMsg == LB_ADDSTRING || nMsg == CB_ADDSTRING)
         {

             LPCSTR message = reinterpret_cast<LPCSTR>(lpnRes);
             UINT res_cp = 1251; //russian
             CString str = CA2W(message,res_cp);
             if (::SendDlgItemMessage(m_hWnd, nIDC, nMsg, 0, (LPARAM)(LPCTSTR)str) == -1)
                 bSuccess = FALSE;

         }


-S

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your proposal.

However, I'd have to switch the code page in line 5 between 1250 and 1251 in order to support Russian, German, and English.
Eventually, it's easier to just initialize the combo box in OnInitDialog() with localized strings.

   for (const auto ids : {IDS_SOLID, IDS_DASH, IDS_DOT})
     m_gridStyleSelection.AddString(LoadStringResource(ids));

where LoadStringResource() internally calls CString::LoadString() and returns the string.






0 Votes 0 ·