visual-c – 为什么ATL调用子类“超类”

对学习ATL感兴趣,我开始阅读
this tutorial并且在阅读这篇
(also related)时感到困惑:

If you want to extend the capabilities of a predefined window class, such as the button or list box controls, you can superclass it.

为什么它被称为超级分类而不是子分类?

最佳答案 超级分类正在编写一个新类,它的行为就像它完全是一个新的控件一样.当你创建CColoredButton的实例时,继承自CButton的CColoredButton将是超类

当您已有控件(可能在资源上)时,您可以将其子类化.这里图中的“控制”被不同地处理,因此术语子类.

任何类都可以表现为超类或子类.您可以调用一些SubclassXX函数/方法来子类化已有的控件.您可以通过调用其Create方法(此处为术语超类)来分配C对象(CColoredButton),从而在运行时创建控件实例.

点赞