HOWTO: Localize Stock ActiveX Property Pages With MFC Resources

ID: Q200555


The information in this article applies to:
  • The Microsoft Foundation Classes (MFC), included with:
    • Microsoft Visual C++, 32-bit Editions, versions 5.0, 6.0


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 way to use these resources is by installing the MFC resource only DLL which is localized for the desired language on the system. For additional information on using the MFC resource only DLLs please see Technote 57 (TN057) titled "Localization of MFC Components"

For additional information, please click the article number(s) below to view the article(s) in the Microsoft Knowledge Base:

Q208983 Using MFC's LOC DLLs
In cases where using the MFC4xLOC DLL is not a viable alternative the only other solution is to create a customized property page that can be localized. This encompasses the following 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 additional information about localized MFC resources, please click the article numbers below to view the articles in the Microsoft Knowledge Base:

Q198846 HOWTO: Create Localized Resource DLLs for MFC Application
Q198536 HOWTO: #include the Localized MFC Resources in an EXE or DLL

Additional query words: kbDSupport CColorPropPage CFontPropPage CPicturePropPage

Keywords : kbole kbCtrl kbCtrlCreate kbDLL kbIntl kbMFC kbVC kbVC500 kbVC600 kbLocalization kbGrpMFCATL
Version : winnt:5.0,6.0
Platform : winnt
Issue type : kbhowto


Last Reviewed: August 24, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.