With external resourcefile dialog with Custom Control not loaded
-
Hi, I am in a problem: An application works just fine, but: As soon as I extract my resources into a resource-only DLL only the dialogs with standard-controls continue to load. (Therefore it is clear, that at least the app finds its resource-DLL.) Every dialog containing CUSTOM CONTROLS fail to load: In CDialog::DoModal() the call to CreateDlgIndirect() returns FALSE, as a result the creation is simply stopped. I tried this with several examples from this site, the behaviour is the same... I assume that somehow the app must get to know there are custom controls in the DLL, but how? Any hints?? Greetings, Martin
-
Hi, I am in a problem: An application works just fine, but: As soon as I extract my resources into a resource-only DLL only the dialogs with standard-controls continue to load. (Therefore it is clear, that at least the app finds its resource-DLL.) Every dialog containing CUSTOM CONTROLS fail to load: In CDialog::DoModal() the call to CreateDlgIndirect() returns FALSE, as a result the creation is simply stopped. I tried this with several examples from this site, the behaviour is the same... I assume that somehow the app must get to know there are custom controls in the DLL, but how? Any hints?? Greetings, Martin
Did you call AfxSetResourceHandle() to tell the framework you are using an external resource dll? If not, load the dll with LoadLibrary() and then pass the handle to AfxSetResourceHandle() in your InitInstance override. If you are already doing it, I don't know what's the problem. Cheers, Paolo.
-
Did you call AfxSetResourceHandle() to tell the framework you are using an external resource dll? If not, load the dll with LoadLibrary() and then pass the handle to AfxSetResourceHandle() in your InitInstance override. If you are already doing it, I don't know what's the problem. Cheers, Paolo.
Hello Paolo, thank you for your time. I got this code from MSDN, which should do the job: m_hInstDLL = ::LoadLibrary("ExtRes.dll"); if ( !m_hInstDLL ) { return FALSE; // failed to load the localized resources } else { AfxSetResourceHandle(m_hInstDLL); // get resources from the DLL } As I wrote, it works with simple elements, it only fails with custom controls and ActiveX-controls. Must I tell the DLL that it has to use these? Or the App, that the DLL uses it? HOW??? Martin
-
Hello Paolo, thank you for your time. I got this code from MSDN, which should do the job: m_hInstDLL = ::LoadLibrary("ExtRes.dll"); if ( !m_hInstDLL ) { return FALSE; // failed to load the localized resources } else { AfxSetResourceHandle(m_hInstDLL); // get resources from the DLL } As I wrote, it works with simple elements, it only fails with custom controls and ActiveX-controls. Must I tell the DLL that it has to use these? Or the App, that the DLL uses it? HOW??? Martin
Hi Martin, I'm sorry, but I can't tell you more. I never tried to use a resource DLL. I also saw your previous message "difference of custom controls from NT to 9x". I replied just to be sure you was using the 'recommended' method. When I have some time, I will do an experiment. As for now, maybe you will have better luck with more experienced programmers. I hope :) Cheers, Paolo.
-
Hello Paolo, thank you for your time. I got this code from MSDN, which should do the job: m_hInstDLL = ::LoadLibrary("ExtRes.dll"); if ( !m_hInstDLL ) { return FALSE; // failed to load the localized resources } else { AfxSetResourceHandle(m_hInstDLL); // get resources from the DLL } As I wrote, it works with simple elements, it only fails with custom controls and ActiveX-controls. Must I tell the DLL that it has to use these? Or the App, that the DLL uses it? HOW??? Martin
Only a few questions: What do you mean with "custom controls"? I suppose you have a static control (or some other standard control) in your dialog resource that gets subclassed later in the code, so why is that dialog different from the others? And if you create a custom control at run-time, then you should have no problems at all, right? How are the custom controls implemented in the code? I have no other ideas... Paolo
-
Only a few questions: What do you mean with "custom controls"? I suppose you have a static control (or some other standard control) in your dialog resource that gets subclassed later in the code, so why is that dialog different from the others? And if you create a custom control at run-time, then you should have no problems at all, right? How are the custom controls implemented in the code? I have no other ideas... Paolo
The AfxSetResourceHandle() only sets the resources for the current module. If the custom controls and Active-X are in another DLL, then you need to create your resource DLL as an MFC Extension DLL, then it will get added to the CDynLinkLibrary list of DLL that will be searched for additional resources. If you visually trace through the code that loads dialog resource templates, or even the CString LoadString member function, you will see examples of this internal CDynLinkLibrary list in use.
-
Only a few questions: What do you mean with "custom controls"? I suppose you have a static control (or some other standard control) in your dialog resource that gets subclassed later in the code, so why is that dialog different from the others? And if you create a custom control at run-time, then you should have no problems at all, right? How are the custom controls implemented in the code? I have no other ideas... Paolo
CustomControl is that icon on the tool bar of the dialog editor with the human head on it. no pun intended. Martine I usually get this kind of promlem when I forget to Register my custom window class. But I don't know why it does not work on win 98. is it diffrent
-
Hi, I am in a problem: An application works just fine, but: As soon as I extract my resources into a resource-only DLL only the dialogs with standard-controls continue to load. (Therefore it is clear, that at least the app finds its resource-DLL.) Every dialog containing CUSTOM CONTROLS fail to load: In CDialog::DoModal() the call to CreateDlgIndirect() returns FALSE, as a result the creation is simply stopped. I tried this with several examples from this site, the behaviour is the same... I assume that somehow the app must get to know there are custom controls in the DLL, but how? Any hints?? Greetings, Martin
Hi there, thank you very much for your help! You've led me to the right path. The LoadLibrary etc. is alright, the problem was the external resource DLL in conjunction with a custom control. I have to register the window class of the control with the WNDCLASS-structure. One element of this is the hInst, which most of the controls (Grid, BitmapViewer etc.) fill with AfxGetInstanceHandle(), which is okay in most cases. But: here I needed AfxGetResourceHandle(), as I have to register the control with the resource DLL!!! I still don't know why it worked with NT, but... Greetings, Martin :-)))))