Switching Menus in dialog based appliaction at runtime

I'm writing an vc++ application that support 4 languages (user may change it at runtime).
I solved this for dialogs, string tables and other ressources by creating a separate resource dll for all four languages. When the user changes the language, the applicable dll is loaded and all resources are used from this dll.

The problem is, that this doesn't seem to work with menus. I need some advice (best with source code fragments) on how to switch menus (not modifying) from one ressource to another.
Second problem is that if I try to load another menu with
hMyMenu = LoadMenu(tmp->GetResHandle(), "IDR_MAIN_MENU\r\n"); or  hMyMenu = LoadMenu(tmp->GetResHandle(), MAKEITRESOURCE(IDR_MAIN_MENU));
I always get back a NULL pointer.
tmp->GetResHandle() returns a handle to the active resource dll and it works fine to load string table entries with LoadString(...).

Does anyone have a good suggestion to this problem
UandIAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZoppoCommented:
Hi Uandl,

What does GetLastError() return when the LoadMenu call fails? Is the IDR_MAIN_MENU defined in the dll's resource.h or in the application's resource.h. If defined in both, are the defined values identical?

Try if finding and loading of the resource is working via FindResource(Ex)()/LoadResource().

ZOPPO
0
UandIAuthor Commented:
GetLastError() returns 1814.
The IDR_MAIN_MENU is defined in the application's resouce.h and in all of the dll's resource.h identical. The difference I make is by the ResourceHandle. The values ind IDR_MAIN_MENU resources have the same menu structure but not the same values (different languages).

GetLastError() returns 998 after the LoadResource() call.

How can I access the menu loaded to global memory with LoadResource()?

Thank for your help!
0
ZoppoCommented:
1814 (ERROR_RESOURCE_NAME_NOT_FOUND) means a resource with this name cannot be found.

998 (ERROR_NOACCESS) means an invalid access to a memory location occured.

Try calling LoadMenu(..., "IDR_MAIN_MENU" ) // without the "\r\n"

>are the defined values identical
I meant the defined values in resource.h, like this:
#define IDR_MAIN_MENU xyz
must be equal for the application and all dll's


Another thing:
are the resources in the dll's from the same language or different languages, i.e:
if you have english and french resources, did you set the resource's language property to 'english' and 'french' or both to 'default'.

ZOPPO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

migelCommented:
Hi!
in MSDN:
1814 - The specified resource name cannot be found in the image file.
check your resource DLL!
you can open it by the MSVC (as "file type" exe and "open as" resource)
0
UandIAuthor Commented:
Hi migel!
Could you be a little more specific. I didn't understand what you meant with
>you can open it by the MSVC (as "file type" exe and "open as" resource)

Hi ZOPPO!
I'm not using the laguage attributes. I've set all the language properties to 'neutral'. I've checked the resource.h files and set them all to the same xyz value (130). They now all look the same: #define IDR_MAIN_MENU 130
I've also tried Try calling LoadMenu(..., "IDR_MAIN_MENU" ) // without the "\r\n"  but it didn't help as well.

Maybe you've got some more ideas?

Thanks!
 
0
ZoppoCommented:
You could mail me your complete project so I could try to debug into it and find the problem ... unfortunately I have no better idea now

zoppo@cdsgmbh.de
0
migelCommented:
Hi:
that is in the MSVC you choose :
File|Open
in the appeared dialog box choose dll you need, and in the "Open As" combo select "Resource" type
0
UandIAuthor Commented:
I checked all the stuff again, set all the resource.h id's to the same value, recompiled all the dll's once more and finally got it right with the following code:
      HMENU      hMyMenu;
      hMyMenu = LoadMenu(tmp->GetResHandle(), MAKEINTRESOURCE(IDR_MAIN_MENU));
      ::SetMenu((tmp->GetMainWnd())->m_hWnd, hMyMenu);
0
migelCommented:
Hi:
that is in the MSVC you choose :
File|Open
in the appeared dialog box choose dll you need, and in the "Open As" combo select "Resource" type
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.