KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q200555: HOWTO: Localize Stock ActiveX Property Pages With MFC Resources

Article: Q200555
Product(s): Microsoft C Compiler
Version(s): 5.0,6.0
Operating System(s): 
Keyword(s): kbnokeyword kbActiveX kbCOMt kbCtrlCreate kbDLL kbIntl kbMFC kbPropSheet kbVC500 kbVC60
Last Modified: 10-JUN-2002

-------------------------------------------------------------------------------
The information in this article applies to:

- The Microsoft Foundation Classes (MFC), included with:
   - Microsoft Visual C++, 32-bit Enterprise Edition, versions 5.0, 6.0 
   - Microsoft Visual C++, 32-bit Professional Edition, versions 5.0, 6.0 
   - Microsoft Visual C++, 32-bit Learning Edition, version 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: CColorPropPage CFontPropPage CPicturePropPage

======================================================================
Keywords          : kbnokeyword kbActiveX kbCOMt kbCtrlCreate kbDLL kbIntl kbMFC kbPropSheet kbVC500 kbVC600 kbLocalization kbIntlDev kbGrpDSMFCATL 
Technology        : kbAudDeveloper kbMFC
Version           : :5.0,6.0
Issue type        : kbhowto

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.