CShadeButtonST

摘要 现在几乎所有东西都可以剥皮或定制。 如果你看过新的Windows XP,你会注意到甚至按钮都可以 看看远离我们知道的。 即使我不喜欢很难的自定义,我也注意到人们有多喜欢按钮控件 名为CxShadeButton,由Davide Pizzolato发布。 我的想法是让引用CButtonST中的一个或两个虚函数可用 控件,让开发人员派生自己的类并实现自定义背景绘制 仍然拥有来自CButtonST控件的所有特性。 为了展示这个新特性,我决定重现CxShadeButton的外观。我从 类CxDib的原始代码以及创建和绘制背景效果的代码。所有 这段代码片段的功劳归于Davide Pizzolato。 虚函数 CButtonST提供了两个虚拟函数。 OnDrawBackground 每次需要绘制按钮背景时都会调用此函数。 如果按钮处于透明模式,则不会调用此函数。 隐藏,复制Code

// Parameters:
//        [IN]    pDC
//                Pointer to a CDC object that indicates the device context.
//        [IN]    pRect
//                Pointer to a CRect object that indicates the bounds of the
//                area to be painted.
//
// Return value:
//        BTNST_OK
//               Function executed successfully.
//
DWORD OnDrawBackground(CDC* pDC, LPCRECT pRect)

OnDrawBorder 每次需要绘制按钮边框时都会调用此函数。 如果按钮处于标准(非平)模式,则不会调用此函数。 隐藏,复制Code

// Parameters:
//        [IN]    pDC
//                Pointer to a CDC object that indicates the device context.
//        [IN]    pRect
//                Pointer to a CRect object that indicates the bounds of the
//                area to be painted.
//
// Return value:
//        BTNST_OK
//               Function executed successfully.
//
DWORD OnDrawBorder(CDC* pDC, LPCRECT pRect)

开发人员从CButtonST派生自己的类,然后在他的新类中实现这两个函数。 例子 CButtonST演示应用程序包括一个显示如何实现新效果的页面。一个类 CShadeButtonST是从CButtonST派生出来的,并且已经实现了新的效果 主要在OnDrawBackground方法中。 讲话 这种体系结构使生成默认不可用的整个范围的按钮成为可能。如果有人实现了 在Windows XP中发现的新按钮的外观和感觉,我将很高兴在下一篇文章中包括他的代码 CButtonST演示应用程序。 本文转载于:http://www.diyabc.com/frontweb/news503.html

原文地址:https://www.cnblogs.com/Dincat/p/13450275.html