Support for Visual C++ 6
Porting this project to Visual C++ 6 was a reminder that new versions of compilers often require code modifications instead of just a simple recompilation. The following issues had to be resolved to get Visual C++ 6 to produce a working control:
- The Video for Windows macros (found in VFW.H), such as capPreviewScale, utilize the function IsWindow, assuming that this function from the Windows API will be used. Apparently, the ATL base classes now include their own IsWindow method, which has a different parameter list. Since C++ compilers first try to match functions against class methods, each such macro generates a compiler error. I bypassed this problem by adding to my control class an IsWindow method that calls the Windows API function.
- Some changes were required in order for VC++ 6 to accept the DIID__ oVFWEvents object. These were mostly semantic and location problems (that is, the statement had to take place before oVFW.h was used).
- Adding events to Visual C++ 6 is much simpler than with earlier versions. An ATL class (object or control) that specifies that it will use events automatically attaches an event interface to the object's class. Now, the event-interface class can be accessed as if it were a standard COM interface (methods can be attached to it, for example). Finally, after VC++ compiles the IDL source to a binary TLB file, right clicking the ATL class and selecting the "Implement Connection Point" menu will create the proxy class and all of the other requirements for the class to fire events.
-- O.L.
Copyright © 1999, Dr. Dobb's Journal