Advertisement

Multiple RC files in MSVC++ project?

Started by March 24, 2001 11:33 AM
11 comments, last by treadwell99 23 years, 10 months ago
felisandria, I tried a similar thing, but it seems mfc only allows you to use on resource at a time (set using AfxSetResourceHandle)... this is for the entire process (this is with using the _USRDLL). It might have gone wrong because I was calling the dll functions from the app, but if so, that is a stupid design.

I ended up fixing it (maybe fixing it is the wrong word) by writing my own wrappers around normal windows functions (similar to mfc), but allowing the individual functions, such as DoModal, to have access to the desired HINSTANCE.

Not a good way to do it, but I found no better, and it worked ok.
You can switch that resource handle all day long, if you like. We regularly have to swap instance handles to load resources from another DLL.

For example, some .dll's we have will load a resource dll and swap its resource handle with the resource dll for the entire life of the dll.

Other times, we only need to temporarily swap instance handles to load some resource, then swap the resource handle back to the original so that you can continue loading resources from the current module instance.

    HINSTANCE hResource = AfxLoadLibrary( "resource.dll" );AfxSetResourceHandle( hResource );CCustomDialog dlg;dlg.DoModal();AfxSetResourceHandle( AfxGetInstanceHandle() );  


The above is a problem we encounter regularly. CCustomDialog class is exported from a particular dll. However, only the class information is exported...not the resource information, dialog template, or other resources, etc..

By temporarily swapping resource handles, you can successfully load the dialog (and its resources).

I don't know if this is the only method though..

HTH,

-Z


Edited by - zach bonham on March 28, 2001 11:13:55 AM
Advertisement
Thanks Zach, I was looking for that call but got an issue I had to deal with dumped on me before I finished the post...

A lot of what I do insists that there be xplatform support in a separate .dll for the dialogs that I bring up. I wasn''t sure if the Afx call would work by itself, but apparently so.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~

This topic is closed to new replies.

Advertisement