You are currently offline, waiting for your internet to reconnect

How to localize the stock ActiveX property page with MFC resources

This article was previously published under Q200555
This article has been archived. It is offered "as is" and will no longer be updated.
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.
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:
  1. 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.
  2. 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.
  3. 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
    • Use the new CLSID provided by Class Wizard in IMPLEMENT_OLECREATE_EX
    • Use the two new string IDs for the page and caption
    • It may be necessary to include some private MFC headers
       #include <afxpriv.h>   #include "../src/oleimpl2.h"   #include "../src/afximpl.h"    						
  4. 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)					
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.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
198846 How to create localized resource DLLs for MFC application

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
198536 How to include the localized MFC resources in an EXE or DLL
CColorPropPage CFontPropPage CPicturePropPage

Article ID: 200555 - Last Review: 02/21/2014 00:31:29 - Revision: 3.1

Microsoft Foundation Class Library 4.2

  • kbnosurvey kbarchive kbhowto kbpropsheet kbintldev kbdll kbctrlcreate kblocalization KB200555