Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MFC: CDialog::Create fails if dialog contains an ActiveX control

269 views
Skip to first unread message

Alex Côté

unread,
Feb 2, 2001, 11:52:55 AM2/2/01
to
Hallo.

I'm trying to show a modeless dialog box containing an ActiveX control
developed in VB6 from a VC6-developed DLL export. When I call the Create
method of my CDialog-derived class, I get a "false" and the dialog box
never shows.

Here's some more information:
- The ActiveX control itself works. I tested it from a Microsoft
Access form.
- My dialog box is shown from a DLL statically linking to the MFC
DLL.
- The dialog box is created from an exported function.
- If I don't put the ActiveX control in my dialog box, the Create
call succeeds and I see my dialog box.
- If I put the ActiveX control in my dialog box (through the IDE's
dialog editor), the Create call fails and I don't get to see my dialog
box.
- I added the ActiveX control to the project and allowed the
ClassWizard to generate a wrapper class for it.
- I let ClassWizard add a data member to my dialog class of my
ActiveX wrapper class type.


What could I be doing wrong?

Thank you
Alexandre Côté


David Lowndes

unread,
Feb 2, 2001, 12:45:52 PM2/2/01
to
>I'm trying to show a modeless dialog box containing an ActiveX control
>developed in VB6 from a VC6-developed DLL export. When I call the Create
>method of my CDialog-derived class, I get a "false" and the dialog box
>never shows.

Alexandre,

You might need to call AfxOleInit().

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Alex Côté

unread,
Feb 2, 2001, 2:29:15 PM2/2/01
to
> You might need to call AfxOleInit().

Hi David,

Where would you call this function? I tried calling it from my exported
function, before I instanciate my CDialog-derived class, and even though
AfxOleInit returned "false" (no error), my CDialog::Create returns with an
error and I still don't get to see my dialog box...

Maybe a few sniplets of code could expose what I obviously am doing wrong...

This is my exported function:

__declspec (dllexport) bool GeneratePDF (char const *MDBName, char const
*ReportName, char const *PDFName) {
AFX_MANAGE_STATE (AfxGetStaticModuleState ())
AfxOleInit ();
CDlg_AccessInterface AccessInterface (AfxGetApp ()->m_pActiveWnd);
AccessInterface.Create (AfxGetApp ()->m_pActiveWnd);
// ...
AccessInterface.DestroyWindow ();
return true;
};


As stated in the MSDN docs, I let the ClassWizard generate a CWinApp-derived
object, and I instanciate that object globally once.

Thanks
- Alex


David Lowndes

unread,
Feb 2, 2001, 6:15:21 PM2/2/01
to
>> You might need to call AfxOleInit().
>
>Where would you call this function? I tried calling it from my exported
>function, before I instanciate my CDialog-derived class

Sorry Alex, I've given you the wrong function name - I think it should
be AfxEnableControlContainer.

Alex Côté

unread,
Feb 7, 2001, 12:02:06 PM2/7/01
to
It worked, by the way! Thanks again for your help

- Alex

0 new messages