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