Re: resource dll problem

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Ajay Kalra" <ajaykalra@xxxxxxxxx> wrote in message
news:u9iqAvtGHHA.924@xxxxxxxxxxxxxxxxxxxxxxx

Why should you have the same resource IDs in the main program and a DLL?
These IDs shoudl all be distinct or you need to explicitly ask for
resources
from a specific DLL. We used multiple resource DLLs, all with distinct
resoruce IDs and put these in a resource chain using CDynLinkLibrary.

I do it the way adamus suggests (same resource IDs in different language
modules) and it works fine.

Schematically I have a

class USERMODULE
{
static HINSTANCE mu_hInstance;
static HINSTANCE mu_hModuleLanguage;
HINSTANCE mu_hOldInstance; // Previous resource instance handle set in
AFX

// member functions...
};

If a foreign language has been selected then

mu_hModuleLanguage

is the handle of the appropriate resource DLL. Otherwise it is NULL.
mu_hInstance is the handle of the standard (English) resource module.

The constructor of this class sets mu_hOldInstance from
AfxGetResourceHandle() and uses AfxSetResourceHandle() to the desired
module. The destructor sets things back with
AfxSetResourceHandle( mu_hOldInstance )

All dialogue operations are wrapped in member functions of this class and
all resources are loaded by preference from mu_hModuleLanguage (if it is
non-NULL) and from mu_hInstance on failure. There's also a static
muLoadString() member which can load strings from the appropriate string
table without constructing a USERMODULE or telling AFX about anything.

It all seems to be working a treat!

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm



.



Relevant Pages

  • Re: How to separate resources in a team?
    ... > Your clients should not be using resource IDs. ... >> edits related code for several days. ... >> If someone else has to edit the same resource file, ...
    (microsoft.public.vc.mfc)
  • Re: Larry Wall, on Tcl
    ... Resource management gets right at the ... variable ids ...
    (comp.lang.tcl)
  • Re: I need a custom CButton
    ... assumed to have the same resource ID as the button. ... Button IDs aren't unique but instead make sense only in the context of the ... turning one's old-fashioned MFC menus into something a bit more like Visual ... Again is there any obvious reason why this might be a bad ...
    (microsoft.public.vc.mfc)
  • Re: How to separate resources in a team?
    ... Your clients should not be using resource IDs. ... > The problem arise when someone edits some dialog in a resource file ...
    (microsoft.public.vc.mfc)
  • Re: MC FILES
    ... "Joseph M. Newcomer" wrote: ... > Only one of them maps numeric IDs to values. ... If you have multiple language resources in a single resource ...
    (microsoft.public.vc.mfc)