Re: Alternative to 'AfxSetResourceHandle'
"Martin" <martin-g@mail.ru> wrote in message
news:1174631935.186190.174270@n76g2000hsh.googlegroups.com...
The problem is that most MFC member functions use
'AfxGetResourceHandle' function, to obtain the default resource
library. For example, 'CBitmap::LoadBitmap' doesn't have a parameter
for instance handle, it uses 'AfxFindResourceHandle'. So do most
members of other classes. It means, I must create the same bitmap in
any resource DLL I use, but I don't want to do that. I want to
translate only localizable resources, the rest ones must reside in the
EXE. Is it possible to do?
For each of my DLLs I define and export a "resource manager" class.
It contains the handle to the DLL as a static member and another HINSTANCE.
The constructor sets the other HINSTANCE to the current resurce handle and
then sets the DLL hInstance as thhe resource handle; the destructor resets
the original hInstance as the resource handle.
Assorted member functions wrap all dialogues whose templates are in the DLL.
In addition there are static members for doing things like loading strings,
which use the static DLL instance handle.
So typically I have for DLL 'A'
{
RM_A rm;
rm.DoDialogueXYZ(.....);
}
or
CString S = RM_A::rmLoadString( nID );
It works well.
( In fact it actually does rather more as it manages alternative resorce
only DLLs for foreign languages.)
I haven't had to write an explicit AfxGet/SetResourceHandle outside this
class members since I started doing it.
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