What is the advantage of the MFC is the advantage of the virtual function table? Some people say that there is a good space. It can save the memory of long virtual functions. For example: If you use virtual functions, Window's base class will be class window {virtual onsize () = 0; Virtual onmove () = 0; Virtual onContextMenu () = 0; ..., etc.,} It is conceivable that each This inherited subclass will bear how much virtual function table, and there are dozens of Windows comes with. Of course I don't want it. However, in addition, there seems to have a point where the machine can use the virtual function, which is not just that MS is helpless. Hey, is it true? Not too! First, what if there is a custom message? Modify the base class? Second, in fact, inter-window inter-window can be seen as a mutual request service, and this service is requested that the form can respond, or it can not respond. This flexibility is that the virtual function method is unable to achieve - if not supported, 嗬嗬, sorry, compile time will be wrong. The request side is only the subclass of CCMDTARGET for the requested party. How is it, it is called cheap and affordable. It is not very good to understand, so MS provides many macros to do this. Look at a specific example. This is an example of TreeCtrl operation. This is a tree that represents the company's organization, the above node has a company ---- Personnel ----- Zhang San ----- Li Si ---- Purchasing ----- Wang 2 ---- - Amplicate three types of nodes, companies, departments, and employees When customers right-click the mouse, the menu popped up for different nodes is of course different. Practice 1, judge the icon of the three nodes (assuming different nodes with different icons) and pop up the menu for different situations. This method is obviously unpleasant, a bit like a classic IF (obj.typeid == ...) do somthing else f (obj.typeid == ..) do somthine else ... The result is full of TreeCtrl's code. Such a judgment code 2, with Class Company, Class Office, Class Person, inherited from ccmdtarget. When INSERT TREEITEM, the object is generated, and the pointer and the inserted item are generated. The method can use the setItemData (pointer to the object). In this case, the method of processing the pop-up menu changes to TreeCtrl :: onContextMenu (...) { CCMDTARGET * P = GetItemData (HSELITEM); P-> SendCommand (wm_contextmenu, point)} is OK. But there is a shortcoming, which takes up too much memory! Every item has multiple SIZEOF (CCMDTARGET), a bit too much.