Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. With external resourcefile dialog with Custom Control not loaded

With external resourcefile dialog with Custom Control not loaded

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlearning
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M Vo
    wrote on last edited by
    #1

    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

    P M 2 Replies Last reply
    0
    • M M Vo

      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

      P Offline
      P Offline
      Paolo Messina
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • P Paolo Messina

        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.

        M Offline
        M Offline
        M Vo
        wrote on last edited by
        #3

        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

        P 2 Replies Last reply
        0
        • M M Vo

          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

          P Offline
          P Offline
          Paolo Messina
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • M M Vo

            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

            P Offline
            P Offline
            Paolo Messina
            wrote on last edited by
            #5

            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

            B B 2 Replies Last reply
            0
            • P Paolo Messina

              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

              B Offline
              B Offline
              Blake Miller
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • P Paolo Messina

                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

                B Offline
                B Offline
                bidoon
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • M M Vo

                  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

                  M Offline
                  M Offline
                  M Vo
                  wrote on last edited by
                  #8

                  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 :-)))))

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups