How to localize the stock ActiveX property page with MFC resources

Article translations Article translations
Article ID: 200555 - View products that this article applies to.
This article was previously published under Q200555
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

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.

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:
  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.

REFERENCES

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

Properties

Article ID: 200555 - Last Review: February 21, 2014 - Revision: 3.1
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
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
Keywords: 
kbnosurvey kbarchive kbhowto kbpropsheet kbintldev kbdll kbctrlcreate kblocalization KB200555

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com