MfcShex MFC Sample


Contents

Back to Kostya Sebov's home page/Professional Content


From the Author

Hi!

I finally made this! I always believe it could be done but never saw the evidence. Now I did it myself and it works! Despite the dirty hacks used, despite Microsoft guys didn't bother to insert the necessary extra line in the MFC source code, despite all, it has been proved, CPropertyPage is suitable to be used in the Explorer.

I even wanted to write a short articte on traps and piftalls that were expecting me on the way but now I doubt I'll do that for free :-). Although I believe the cource code is quite self-descriptive and the ReadMe.txt should help, I'm sure there will be a lot of questions. I don't mind at all-- that will let me compile simple FAQ list. I also plan to add soon a list of help and MSDN articles that made all this possible.

If you have questions or comments feel free to e-mail me. I'll do all my best to answer and help.

Good luck to all!

Kostya.


ReadMe.txt

December 20, 1997
Kiev, Ukraine.

MFCSHEX.DLL is a Windows (95+/NT 4.0+) shell extension using MFC native means whenever possible and convenient.

The main goal is to demonstrate that one can effectively use CPropertyPage derivative class with full MFC-specific features support (e.g. Class Wizard editing, data exchange and validation, message maps) to implement a property sheet extension. The icon handler has also been implemented for demonstration and debugging purposes.

The resulting DLL is a COM self-registering in-proc server built as an MFC regular DLL linked to DLL-based MFC. Although I have not tried to build UNICODE version for NT, the source code was written to support _UNICODE-conditional builds.

Self-registration features has been encapsulated in a single function (RegisterShellExtension) that can register various shell extensions based on arguments and flags passed. This function is called from the OCX-standard DllRegisterServer(), which allows to register the extension using regsvr.exe or from the Visual Studio Tools>Register Control menu. That is why the REG file is NOT provided.

COM-interfaces requited by the shell extension spec are implemented using CCmdTarget interface maps. Object life-time management is implemented by implicit COleObjectFactory objects instantiated by IMPLEMENT_OLECREATABLE macro. Object CLSID and ProgID, which are introduced by that macro, are also used in the C++ template overloaded versions of RegisterShellExtension function.

Shell-extension-compatible CPropertyPage-derivative class is called CGenericPage. Unfortunately genuine MFC implementation of CWnd/CPropertyPage fails to correctly manage MFC contexts when the pages are created by CreatePropertySheetPage API and controlled through HPROPSHEETPAGE handles. CPropertyPage fills this gap by overriding the property page hook function, provided by MFC. Note, that it uses "highly" undocumented features of MFC and thus may break in the future versions.

The sample has been created, tested and debugged using Microsoft(R) Visual C++ (member of the Developer Studio suite) version 5.0 (NO service packs applied). It has been successfully tested under Windows NT 4.0 Server SP3 with IE 4.0 installed, as well as under Windows 98 beta 1. The technique used in the sample has been incorporated for long in a commercial product.

 

Copyright (C) 1997 Kostya Sebov.
Courtesy of Intelligent Systems (Boston-Kiev), which allowed me to publish the code and retain my copyright despite that portions of the sample has been developed as a part of some commercial products.

This sample can be freely redistributed as long as (1) it retains this copyright notice and (2) no fee is charged with the sole exception for shipping/handling/transfer coverage. The sample source code can be used free of charge in any application (free or commercial) provided the thee application functionality is considerably wider than the sample's one. Any other usage is prohibited unless explicitly granted by the author (Kostya Sebov).

NO WARRANTY OF ANY KIND EXPRESSED OR IMPLIED! THIS SAMPLE IS PROVIDED AS IS! YOU MAY USE IT ONLY AT YOUR OWN RISK!

In some cases support may be provided (but NOT guaranteed) upon request through e-mail to Kostya Sebov (mailto:sebov@is.kiev.ua). Constructive comments are also welcome.


Download MfcShex.zip

You can use the below location to downloaded zipped source code, resource and project files for the sample.

Virtual community on the Internet, CA, USA mfcshex.zip

 


Back to Kostya Sebov's home page.

CopyrightŠ1997-1999 Kostya Sebov.
Last revised: March 23, 1999.