Microsoft KB Archive/200555

= How to localize the stock ActiveX property page with MFC resources =

Article ID: 200555

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q200555

<div class="summary_section">

SUMMARY
MFC provides localized versions of the standard OLE color, font, and picture property pages. This article provides two methods for using these resources in MFC property pages.

<div class="moreinformation_section">

MORE INFORMATION
The first method for using these resources is to install the MFC resource-only DLL that is localized for the language that you want on the system. For more information about how to use the MFC resource-only DLLs, see Technote 57 (TN057) titled, "Localization of MFC Components." For more information, click the following article number to view the article in the Microsoft Knowledge Base:

208983 How to use MFC LOC DLLs

If the MFC4xLOC DLL is not a workable alternative, the only other solution is to create a customized property page that can be localized. To do this, follow these steps: <ol> Copy the stock property page dialog resource from the appropriate localized MFC resource only DLL (usually found in mfc\include\Afxctl.rc). You can rename the ID if you like.</li> Using Class Wizard and the new dialog resource ID, create an OLE property page class derived from CStockPropPage (don't forget to provide a string ID for the page and its caption). If you get a Class Wizard error about being unable to open a file, just ignore it.</li>  Copy the code from the corresponding MFC class representing the stock property page. For example, if you were customizing the CFontPropPage dialog box, you'd copy the code from mfc\src\ppgfont.cpp and mfc\include\afxctl.h. Some modifications will be necessary.

 Change the class name to your new OLE property page class. For example, change all occurrences of CFontPropPage to CMyLatinFontPage</li> Use the new CLSID provided by Class Wizard in IMPLEMENT_OLECREATE_EX</li> Use the two new string IDs for the page and caption</li> It may be necessary to include some private MFC headers</li></ul>

#include <afxpriv.h>  #include "../src/oleimpl2.h"   #include "../src/afximpl.h"                        </li>  As with adding any OLE property page, make sure to add the entries into the BEGIN_PROPPAGEID macro in the control's implementation file. For example: BEGIN_PROPPAGEIDS(CSuperCtrl, 2) PROPPAGEID(CSuperPropPage::guid) PROPPAGEID(CMyLatinFontPage::guid) END_PROPPAGEIDS(CSuperCtrl) </li></ol>

The reason that the creation of a customized property page is necessary is that the function calls for the creation and usage of resources does not originate from the application when creating stock property pages, the function calls originate from the COM subsystem. The module state used to determine where to load the resources is the calling user module. This means the resources in the user module and extension DLLs (which could be resource only DLLs) are used. Therefore the resources used by the stock property pages are restricted to resources in the MFC DLL.

<div class="references_section">