This article only describes the main design parts of the COM application framework, and more, more detailed documentation is available in the download package for documentation and source code.
First, design instructions
The COM application framework is designed to use COM technology for standard Microsoft Windows multiple document processing applications. So the need for multiple document processing applications is not written more. If you are not aware of this, see MSDN or other books on the basics of programming.
The COM application framework is divided into two types, one is the COM multi-document application framework and the second is the single document application framework. Here we only introduce a multiple-document application, not a single document application.
The COM application framework is built in a separate AIFrame.DLL file, and all functions are operated through COM interfaces. The COM application framework will be designed using a combination of the following two libraries, 1. Using the Mfc+atl combination, 2. Using the Wtl+atl combination, the following is a description of the advantages and disadvantages of the two combinations, and finally the optimal combination is selected.
1. Use Mfc+atl Combination chart:
2. Use WTL+ATL Combination chart:
It's easy to see from the two drawings above that the COM application framework is developed using the MFC+ATL combination, where MFC has a layer of function calls, and code execution slows down. Small programs may not be visible, large programs are obvious. If you develop a COM application framework using the WTL+ATL combination, there will be no more calls, and the code executes very quickly, just as it does with the Win32 SDK, because WTL is the template code and there is no one-layer function call after compilation. So the COM application framework will be designed using a WTL+ATL combination, which may be the best solution.
Second, the general design
1. Data View
The so-called Data view, is added to the "COM application framework" Every window, no matter what the window is used for, or what shape, collectively referred to as the Data view.
The data Views added to the COM application framework by all client programs must inherit from the Idataview pure virtual interface and must be. This will make the COM application framework work properly.
Data View pure Virtual interface: Idataview. The parent class is IDispatch.
2. Response function of command
Function name: NotifyCommand (UINT codenotify, UINT CmdID, Variant_bool *bhandle);
Parameters: codenotify-Notification code, not currently in use.
cmdid– a command ID, either a menu or a button in the toolbar.
bhandle– If the command also continues down the path set to VARIANT_TRUE, no downward path is set to VARIANT_FALSE.