Menu Item problem (was Notepad not remaining language selection)
dmitry at baikal.ru
Fri Mar 1 03:03:49 CST 2002
"Sylvain Petreolle" <spetreolle at yahoo.fr> wrote:
> It seemed that wineconsole has the correct
> implementation to use langage dependant menus.
> I looked in the code and saw the LoadString function
> looks as the main key to have string resources loaded
> with the local system language.
I coudln't find any LoadString in the wineconsole code. Moreover
I accidently found a bug in wineconsole_Fr.rc (French resources)
which contains in the very first line LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT.
Very likely a cut&paste bug.
> So how could I rewrite the language resource files
> to handle them like wineconsole do ?
> I'm a newbie in windows programming for now(not C
Basically all you need is to surround the resources targeted
for different languages by LANGUAGE [main_lang],[sub_lang]
statement. Then just use conventional LoadString, LoadMenu,
etc. functions. They use FindResource internally, which in turn
does search for language dependent resources using algorithm
described in loader/pe_resource.c/PE_FindResourceW.
See dlls/kernel/locale_rc.rc, dlls/kernel/nls/*.nls for string
tables for many different languages but using the same IDs.
They are used by ole/ole2nls.c/GetLocaleInfo.
A much more powerful way to do things would be to use FindResourceEx,
but I would not recommend it, because it adds more power, but requires
more attention since FindResourceEx is not allowed to return any language
resource like FindResource (see PE_FindResourceExW).
Here is an example of using of FindResourceEx to create a dialog
explicitly requesting English resources:
HANDLE hRsrc = FindResourceEx(hInstance, RT_DIALOG, MAKEINTRESOURCE(1), \
VOID *tmplate = LoadResource(hInstance, hRsrc);
DialogBoxIndirectParam(hInstance, tmplate, 0, MyDlgProc, 0);
As I mentioned above, you would better replace FindResourceEx by
simple FindResource here. It will provide a graceful rollback in the
case if resource for a specific language is not exist.
More information about the wine-devel