Re: Module handle of a given object instance
On Fri, 18 Jul 2008 00:46:45 -0700 (PDT), Andy pandy 2
<devteam@transvalor.com> wrote:
On 17 juil, 18:17, "Giovanni Dicanio" <gdicanio@_NOSPAM_email_DOT_it>
wrote:
"Doug Harrison [MVP]" <d...@mvps.org> ha scritto nel messaggionews:mjpu74lek350vr29i74q6sc4eirilkketd@4ax.com...
but I don't see how it
would help if the modules are sharing the same heap
You're right...
Giovanni
Thank you for all the discussion about the topic. The bottom line is
this :
In my base class, I have a method that loads a bitmap using LoadImage.
The bitmap is identified by its resource ID, stored as a member in the
base class.
LoadImage needs a handle to module containing the resource, which is
the module in which my object was instantiated - not the module in
which LoadImage is executed.
I wonder if AfxFindResourceHandle can help - not the
FindObjectInstanceHandle I was looking for - but it might do the job ?
It will work if your resource IDs are unique between modules. Extension
DLLs enable this by executing the following code in their DllMain:
if (!AfxInitExtensionModule(ElGuiToolDLL, hInstance))
return 0;
new CDynLinkLibrary(ElGuiToolDLL);
I would think that if you're sharing classes between modules as you've
described, you need to be using an extension DLL. If you're not, or you are
and your resource IDs aren't unique, you will have to do as Giovanni says
and pass module handles around.
--
Doug Harrison
Visual C++ MVP