简体   繁体   中英

Loading a “special” MFC control from a Satellite DLL

I have an MFC application using satellites DLLs in order to support the multilingualism. I am using Visual Studio 2010.

I am able to change the language of the core part of the application without any problems. Things go wrong when I try to load a modeless dialog containing a "special" MFC control ( CMFCColorButton , CVSListBox , etc).

The problem occurs at the following statement :

m_dlg->Create(SOME_IID, this); // returns false

How should I proceed to load a "special" MFC control from a satellite DLL?

You must register their classes before you reach OnCreate() . For custom controls, this is typically done in the constructor:

CMyClass::CMyClass()
{
    // Pseudo code
    m_mfcColorButton.RegisterWindowClass(AfxGetResourceHandle());
}

For MFC controls, I bet there is an initialization function that needs to be called.

I had the same problem: my CDialog - derived class failed in DoModal if I use localized resource dll. It contains CMFCColorButton on resource template.

My solution was to call in a resource dll AfxRegisterMFCCtrlClasses();

class CMyApp: public CWinApp
{
    BOOL InitInstance()
    {
        AfxRegisterMFCCtrlClasses();
        return CWinApp::InitInstance();
    }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM