tags:

views:

19

answers:

1

Hi!

We have a very big MFC application that have 16 projects in the solution. Each project is a DLL. Four(4) of these projects are what we call "Network". In each network, there is a dialog that we will call X. This dialog is VERY different in each of the network but the name of the dialog itself is the same in each of the resource.h. In resource.h, they also have the same ID (value).

What happend right now is that when I'm on the network 1 and load the class with the dialog X, it try to use the dialog from Network 2. Since they don't have all the same control in it, it crash in the DoDataExchange trying to find controls that don't exist in the other network.

Does anybody know what can cause this? Attemps at changing the name in the network that do not work didn't change anything since it use the ID...

I always think that the DLL was using it's own resource.h but now it's seems that it's not the case...

Can anybody help? Thanks

DarkJaff

+1  A: 

It sounds like you need to call AfxSetResourceHandle to specify the DLL from which to load the dialog.

Edit: Given your description, you'll basically need to call this with the right value every time you display a dialog. Changing things like the DLL load order isn't going to fix the problem -- at any given time, MFC is going to try to use one order for the DLLs/EXE to load all dialogs, and this is modal, so it stays the same until you change it. Given the same resource ID needing to refer to different resources at different times, you need to tell it which one at any given time -- otherwise, you get the first thing it finds with the right ID, and almost no control over which that will be.

Jerry Coffin
Thanks for the answer. I try it and it works... BUT like MSDN said: 'The instance or module handle to an .EXE or DLL file from which the application's resources are loaded.' and this is bad because other dialog might use other dll than this one so other part from the application could not work... All of the dll are loaded, I feel it's something related to the order of the load but I can't find where it is...
DarkJaff
Thanks for your answer. I finaly used the solution in this post: (http://www.codeguru.com/forum/archive/index.php/t-304181.html) so in the destructor, I put back everything like before and it works great. Thank you.
DarkJaff