Subject: Class doesn't work in COM, but it does in an App.

Category: COM

Hello all,

Firstly I'd like to quickly thank all people who have replied to my other post. I've really appreciated the time taken to help me out.

OK, here's the problem. I have a class (let call it CMyClass) that has one function Go(), and a member of type CPropertySheet, the CPropertySheet has 3 CPropertyPages added to it. The function CMyClass::Go() calls the CPropertySheet:oModal() function to get it all going.

If I create a variable of type CMyClass and call CMyClass::Go() in a Win32App it works fine. But if I have a COM class CMyComClass that has interface IMyComClass, and have a member variable of CMyComClass of type CMyClass and an interface function Go() which calls CMyClass::Go() it doesn't work. I've spent hours debugging the **** thing and found out where it goes wrong.

During the DoModal function it calls CPropertySheet::BuildPropPageArray, which in turn calls CPropertyPage::PreProcessPageTemplate, the code for which can be found in the MFC source DLGPROP.CPP

The lines that aren't working are as follows


HRSRC hResource = ::FindResource(psp.hInstance,psp.pszTemplate,RT_DIALOG);
HGLOBAL hTemplate = LoadResource(psp.hInstance,hResource);
pTemplate = (LPCDLGTEMPLATE)LockResource(hTemplate);
ASSERT(pTemplate != NULL);




The execution of the app and the COM code (which is in a DLL), are identical up until the first line, where for some reason the FindResource function returns NULL in the COM case and returns the correct pointer in the App case.

So, does anyone know what's going on, I can't think why this would happen.

Many regards and thanks in advance

Daniel.