The information in this article applies to:
SYMPTOMSAdditional resources specified in a dialog template of a dialog implemented in an extension DLL will be displayed incorrectly or not displayed at all. That can affect icons, bitmaps, and menus that are specified in a dialog template. CAUSE
The implementation of the CDialog class was changed in MFC version 4.0. The
previous implementation of CDialog used a ::DialogBox() call to create a
modal dialog and passed an instance handle obtained from a call to
AfxFindResourceHandle() as a handle of the module where resources were
stored. It was possible to call AfxSetResourceHandle() or use an extension
DLL to find a dialog template that was stored in another module. RESOLUTIONTo correct this problem, you have to set the current handle to be the one that corresponds to the module containing a dialog template. You also need to reset the handle back to the old value before proceeding with any code that involves the dialog. The easiest way to achieve this is to override DoModal in your CDialog derived class as in this example:
Here m_hInstSave is a data member of CMyDialog of type HINSTANCE. The
variable afxCurrentInstanceHandle is used by MFC to store the current
instance handle. Its value is returned from AfxGetInstanceHandle(), and it
is defined in Afxwin.h.This implementation sets the current instance handle to the one that is returned from AfxFindResourceHandle(), which searches through the list of available extension DLLs for a dialog template. If you are using a resource only DLL, you will probably use AfxSetResourceHandle() to set the MFC current resource handle to the one that corresponds to the DLL. In that case, you can set afxCurrentInstanceHandle either directly using the same value or with a value returned from AfxGetResourceHandle(). To reset the current instance handle back to the saved value, you need to have a handler for the WM_INITDIALOG message, OnInitDialog, with the following code:
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual C++, 32-bit Edition, version 4.1. REFERENCESFor the implementation of the CDialog class, refer to the Dlgcore.cpp file, located in MFC source code directory, \Msdev\Mfc\Src. Additional query words: kbVC400bug 4.00 dialog template DLL resource-only vcfixlist410
Keywords : kbMFC KbUIDesign kbVC |
Last Reviewed: August 5, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |