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. custom control problem

custom control problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 2 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.
  • L Offline
    L Offline
    Lior Shoval
    wrote on last edited by
    #1

    Hi. I have a problem which relates to custom control. let me try to describe it: description of dll1: holds CMyPropertySheet and CMyPropertyPage (customized deriviations from MFC) holds CPropertySheetMediator which is a singleton and is incharg of creating the CPropertySheet and adding the property pages to it. description of dll2: hold CGenPropertyPage which derives from CMyPropertyPage and holds a member of MyCustomControl which is the old thing this property page displays description of dll3: this is (like the first two) mfc extension dll which is dynamiclly linked to mfc (not statically) and is a dynamic library (not static .lib file) the custom control calls RegisterClass in it's constructor to register it's window class. description of application: the application calls a method of CPropertySheetMediator to create an instance of CMyPropertySheet which contains only one page, CGenPropertyPage then the application calls DoModal on that propertysheet instance it get's back from the mediator. for some odd reason, DoModal fails (tracing into mfc code reveals that do WM_INITDIALOG message is sent to the propertysheet but is not received by it) At the begining i thought it was a resources problem, but it isn't. If i remove the custom control place holder from CGenPropertyPage, the sheet is displayed and runs without a problem, so i figured it has something to do with the window class registration. ofcourse i should mention that if CGenPropertyPage resides in the application and not in dll2 everything works just fine. Any ideas ? Thanks.

    R 1 Reply Last reply
    0
    • L Lior Shoval

      Hi. I have a problem which relates to custom control. let me try to describe it: description of dll1: holds CMyPropertySheet and CMyPropertyPage (customized deriviations from MFC) holds CPropertySheetMediator which is a singleton and is incharg of creating the CPropertySheet and adding the property pages to it. description of dll2: hold CGenPropertyPage which derives from CMyPropertyPage and holds a member of MyCustomControl which is the old thing this property page displays description of dll3: this is (like the first two) mfc extension dll which is dynamiclly linked to mfc (not statically) and is a dynamic library (not static .lib file) the custom control calls RegisterClass in it's constructor to register it's window class. description of application: the application calls a method of CPropertySheetMediator to create an instance of CMyPropertySheet which contains only one page, CGenPropertyPage then the application calls DoModal on that propertysheet instance it get's back from the mediator. for some odd reason, DoModal fails (tracing into mfc code reveals that do WM_INITDIALOG message is sent to the propertysheet but is not received by it) At the begining i thought it was a resources problem, but it isn't. If i remove the custom control place holder from CGenPropertyPage, the sheet is displayed and runs without a problem, so i figured it has something to do with the window class registration. ofcourse i should mention that if CGenPropertyPage resides in the application and not in dll2 everything works just fine. Any ideas ? Thanks.

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      My guess is that it can load the template fine when the propety sheet is being created, but it is failing to load the custom control info when it creating the CPropertyPage object and initialising the controls. It may be necessary for you to make sure that the correct resources are selected at the time the OnInitDialog()/OnInitialUpdate() for the CPropertyPage is called. So you would need to do:

      OnInitDialog/OnInitialUpdtate()
      {
      HINSTANCE old = AfxGetResourceHandle();
      AfxSetRexourceHandle(hInstanceOfDll);
      //call base class
      CPropertyPage::OnInitDialog()/OnInitialUpdate();
      AfxSetResourceHandle(old);
      ...
      }

      This is caused by your DLL being dynamically loaded and not being added to the MFC DLL resource chain. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003

      L 1 Reply Last reply
      0
      • R Roger Allen

        My guess is that it can load the template fine when the propety sheet is being created, but it is failing to load the custom control info when it creating the CPropertyPage object and initialising the controls. It may be necessary for you to make sure that the correct resources are selected at the time the OnInitDialog()/OnInitialUpdate() for the CPropertyPage is called. So you would need to do:

        OnInitDialog/OnInitialUpdtate()
        {
        HINSTANCE old = AfxGetResourceHandle();
        AfxSetRexourceHandle(hInstanceOfDll);
        //call base class
        CPropertyPage::OnInitDialog()/OnInitialUpdate();
        AfxSetResourceHandle(old);
        ...
        }

        This is caused by your DLL being dynamically loaded and not being added to the MFC DLL resource chain. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003

        L Offline
        L Offline
        Lior Shoval
        wrote on last edited by
        #3

        Thanks, but the problem is that the page's OnInitDialog doesn't get called... Again, tracing into DoModal code shows that the dialog template (atleast for the sheet) is found and that's it. Any other idea ?

        R 1 Reply Last reply
        0
        • L Lior Shoval

          Thanks, but the problem is that the page's OnInitDialog doesn't get called... Again, tracing into DoModal code shows that the dialog template (atleast for the sheet) is found and that's it. Any other idea ?

          R Offline
          R Offline
          Roger Allen
          wrote on last edited by
          #4

          Can you post the code from your dynamically loaded DLL for the propertypage class. It could be that when the page gets registered, it oly uses the CPropertyPage base class and not the CYourPage class when the message map entries are getting processed. Also the code which adds the page to the sheet may be useful in understanding the problem as well. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003

          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