Home Dashboard Directory Help
Search

Satellite DLLs doesn't work when new MFC controls like CMFCButton are used in an MBCS project by Martin Richter


Status: 

Closed
 as Fixed Help for as Fixed


2
0
Sign in
to vote
Type: Bug
ID: 686157
Opened: 8/30/2011 3:04:06 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
1
Workaround(s)
view
1
User(s) can reproduce this bug

Description

If dialog with a new MFC control like CMFCButton is loaded from a satellite DLL the dialog is not loaded when the project is a MBCS project.
Details
Sign in to post a comment.
Posted by zdf on 10/18/2012 at 1:06 PM
Is there any workaround? I have wasted hours trying to figure out the problem. I am trying to add a dialog to an already existing MBCS DLL.

Thank you.
Posted by Martin Richter on 9/8/2011 at 10:48 PM
I think that the classes MFCButon and so son, must be globally registered.
Remember that the MFC DLL may be loaded from any context.
Yes the instance handle must match to findthe class, but because the classes are already globally registered with a Common Control 6 manifest.
- Martin
Posted by Microsoft on 9/8/2011 at 9:25 AM
Hello Martin,

Thanks for the report. This issue has been fixed in MFC for the next major release of Visual Studio. If the dialog fails to load when the resource handle is used, the instance handle will be used as a fallback.

Pat Brenner
Visual C++ Libraries Development
Posted by MS-Moderator08 [Feedback Moderator] on 8/31/2011 at 12:57 AM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 8/30/2011 at 3:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by zdf on 10/19/2012 at 8:07 AM
1.    Copy AfxRegisterMFCCtrlClasses and DoRegisterWindowClass to “dllmain.cpp”.
2.    Change their names (add a “Local” prefix, for instance).
3.    Change HINSTANCE hInst = AfxGetInstanceHandle() to HINSTANCE hInst = YourDLL.hModule
4.    Call LocalAfxRegisterMFCCtrlClasses from DllMain.

Example:

// dllmain.cpp
// ...
static AFX_EXTENSION_MODULE RegularDLL = { NULL, NULL };

namespace
{
void LocalDoRegisterWindowClass(LPCTSTR lpszClassName, LPCTSTR lpszBaseClassName)
{
// ...
    HINSTANCE hInst = RegularDLL.hModule;//AfxGetInstanceHandle();
// ...
}

void LocalAfxRegisterMFCCtrlClasses()
{
    LocalDoRegisterWindowClass(_T("MFCButton"), WC_BUTTON);
// ...
}

} // namespace

REGULAR_API void test()
{
    C_MFCControlsDlg d;
    d.DoModal();
}

extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
//...
        new CDynLinkLibrary(RegularDLL);
        LocalAfxRegisterMFCCtrlClasses();
// ...
}
File Name Submitted By Submitted On File Size  
MFCNewControlsDlg.zip 8/30/2011 133 KB