EnumWnd v1.08
Welcome to EnumWnd, a tutorial ATL COM dll which I developed
while studying the Collections and Enumerator support provided by ATL. While
reading the "ATL Internals" book by Brent Rector and Chris Sells, I was
struggling with Chapter 7 which explains COM Enumerators. To improve my
understanding of this, I decided to develop a real world example. The simplest
collection I could think of was Top Level Windows which is what is returned by
the Win32 SDK call "EnumWindows".
Usage
- EnumWnd is a standard COM DLL developed in ATL in VC 2017 or higher.
- It provides both dual and custom Interfaces. So basically it can be
called from any COM enabled language / environment.
- Two example collections are provided, namely the class "TopLevelWindows" which is a simple collection of top level window captions
and "TopLevelWindows2" which is a collection of COM objects which provide the
IEnumWindow interface. This allows access to such attributes such as
"Class", "Caption". "Style" etc. etc.
- Both collections provide support for the "For Each" collection syntax in
Visual Basic 6 (i.e. it shows how to use the DISPID_NEWENUM attribute)
- Both collections provide access to items in the collection without
requiring you to explicitly access the Items attribute (i.e. it show how to
use the DISPID_VALUE IDL attribute).
- The EnumWindow class is not externally creatable and can only be
accessed through the TopLevelWindows2 class. This is achieved by using the
ATL macro OBJECT_ENTRY_NON_CREATEABLE in the object map.
- The _NewEnum IDL method includes the restricted attribute to hide it
from scripting type library browsers.
- Implemented using ATL only, no dependencies on MFC or any non-standard
dlls. This means a small < 350k dll!.
- For my own understanding I decided to store the window HWND's in an ATL
CSimpleArray instead of an STL container.
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
History
v1.08 (7 May 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.07 (11 April 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.06 (30 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
v1.05 (17 November 2019)
- Updated initialization of various structs to use C++ 11 list
initialization
v1.04 (3 June 2019)
- Updated copyright details.
- Updated the code to clean compile on VC 2019
v1.03 (27 December 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
v1.02 (17 January 2017)
- Updated copyright details.
- Updated the code to now require at a minimum VC 2010.
- Updated the code to clean compile in VC 2010 - 2015.
- Removed the MinSize project configurations.
- Updated the code to compile cleanly using /analyze
- Updated the code to include x64 build configurations
- Added SAL annotations to all the source code.
- Replaced NULL throughout the codebase with nullptr.
- The DLL now supports the "DllInstall" registration function.
v1.01 (6 April 2002)
- Fixed a problem with the registration of the class EnumWindow.
- Updated the sample app to use a Reference from the registry rather than
from a location.
- Add the restricted IDL attribute to the _NewEnum methods to hide that
method from scripting type library browsers.
v1.0 (20 January 2002)
References
- The book "ATL Internals" by Brent Rector and Chris Sells.
Contacting the Author
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
7 May 2022