CButtonST v3.9 (MFC Flat 按钮)






4.95/5 (230投票s)
1999年11月25日
9分钟阅读

3492714

92978
一个功能齐全的自绘按钮类 - 它拥有一切!
摘要
CButtonST
是一个从 MFC 的 CButton
类派生的类。
通过这个类,您的应用程序可以拥有标准的按钮,或者拥有全新的、现代的“扁平化”风格的按钮!
CButtonST
的主要特性是
- 标准的
CButton
属性 - 按钮上的文本和图标(或位图)
- 仅文本或仅图标/位图按钮
- 支持任何大小的图标(最多256色)
- 支持位图
- 支持透明按钮(用于位图应用程序)
- 标准或扁平化按钮样式
- 运行时可在扁平化和标准样式之间切换
- 按钮可以有两个图像。鼠标悬停在按钮上时显示一个图像,鼠标移开时显示另一个图像(仅适用于“扁平化”按钮)
- 所有颜色均可自定义
- 可通过
DDX_
调用使用 - 可在 DLL 中使用
- 可动态创建
- 每个按钮都可以拥有自己的鼠标指针
- 按钮在高亮显示时,即使窗口不活动,也会像 Internet Explorer 中那样显示
- 内置支持多行工具提示
- 内置基本菜单支持
- 内置支持属主绘制菜单(使用
BCMenu
类) - 内置基本声音支持
- 可以派生以创建默认未提供的其他按钮样式
- 包含完整的源代码!
- 兼容 UNICODE
- 在现有应用程序中实现成本为零
点击 这里 查看使用 CButtonST
创建的真实应用程序。
如何将 CButtonST 集成到您的应用程序中
在您的项目中,包含以下文件
- BtnST.h
- BtnST.cpp
从 3.5 版本开始,CButtonST
现在支持使用 BCMenu
类创建的菜单。
这个第三方类使您能够显示菜单,并具备最新 Microsoft 产品甚至 Windows XP 中看到的最新视觉样式。
最新的 BCMenu
版本可以在 这里 找到。
要启用对 BCMenu
的支持,必须在 BtnST.h 中启用以下两行
#define BTNST_USE_BCMENU
#include "BCMenu.h"
此外,还必须在您的项目中包含以下文件
- BCMenu.h
- BCMenu.cpp
注意:请注意,当启用 BCMenu 支持时,SetMenu 方法接受的参数是不同的!
从 3.6 版本开始,CButtonST
可以在特定的按钮状态下播放声音。
要启用声音支持,必须在 BtnST.h 中启用以下行
#define BTNST_USE_SOUND
这提供了对 SetSound
方法的访问。
静态创建 CButtonST 对象
使用对话框编辑器,创建一个标准按钮,例如命名为 IDOK(您无需将其设置为属主绘制),并为此按钮创建一个成员变量
CButtonST m_btnOk;
现在将按钮附加到 CButtonST
。对于基于对话框的应用程序,在您的 OnInitDialog
中
// Call the base-class method
CDialog::OnInitDialog();
// Create the IDOK button
m_btnOk.SubclassDlgItem(IDOK, this);
或者在您的 DoDataExchange
中
// Call the base method
CDialog::DoDataExchange(pDX);
// Create the IDOK button
DDX_Control(pDX, IDOK, m_btnOk);
动态创建 CButtonST 对象
在您的应用程序中,为按钮创建一个成员变量。请注意,这个变量是一个指针
CButtonST* m_pbtnOk;
现在创建按钮。对于基于对话框的应用程序,在您的 OnInitDialog
中
// Call the base-class method
CDialog::OnInitDialog();
// Create the IDOK button
m_pbtnOk = new CButtonST;
m_pbtnOk->Create(_T("&Ok"), WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP,
CRect(10, 10, 200, 100), this, IDOK);
// Set the same font of the application
m_pbtnOk->SetFont(GetFont());
请记住销毁按钮,否则将导致内存泄漏。例如,可以在您的类析构函数中完成此操作
if (m_pbtnOk) delete m_pbtnOk;
类方法
SetIcon
(使用多尺寸资源)
- 为按钮分配图标
- 任何先前的图标或位图都将被删除
// Parameters:
// [IN] nIconIn
// ID number of the icon resource to show when the mouse is over the
// button. Pass NULL to remove any icon from the button.
// [IN] nCxDesiredIn
// Specifies the width, in pixels, of the icon to load.
// [IN] nCyDesiredIn
// Specifies the height, in pixels, of the icon to load.
// [IN] nIconOut
// ID number of the icon resource to show when the mouse is outside
// the button. Can be NULL.
// If this parameter is the special value BTNST_AUTO_GRAY (cast to int)
// the second icon will be automatically created starting from nIconIn
// and converted to grayscale.
// If this parameter is the special value BTNST_AUTO_DARKER (cast
// to int) the second icon will be automatically created 25%
// darker starting from nIconIn.
// [IN] nCxDesiredOut
// Specifies the width, in pixels, of the icon to load.
// [IN] nCyDesiredOut
// Specifies the height, in pixels, of the icon to load.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
//
DWORD SetIcon(int nIconIn, int nCxDesiredIn, int nCyDesiredIn,
int nIconOut = NULL, int nCxDesiredOut = 0, int nCyDesiredOut = 0)
SetIcon
(使用资源)
- 为按钮分配图标
- 任何先前的图标或位图都将被删除
// Parameters:
// [IN] nIconIn
// ID number of the icon resource to show when the mouse is over the
// button.
// Pass NULL to remove any icon from the button.
// [IN] nIconOut
// ID number of the icon resource to show when the mouse is
// outside the button. Can be NULL.
// If this parameter is the special value BTNST_AUTO_GRAY (cast to int)
// the second icon will be automatically created starting from
// nIconIn and converted to grayscale. If this parameter is the
// special value BTNST_AUTO_DARKER (cast to int) the second
// icon will be automatically created 25% darker starting from nIconIn.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
//
DWORD SetIcon(int nIconIn, int nIconOut = NULL)
SetIcon
(使用句柄)
- 为按钮分配图标
- 任何先前的图标或位图都将被删除
// Parameters:
// [IN] hIconIn
// Handle fo the icon to show when the mouse is over the button.
// Pass NULL to remove any icon from the button.
// [IN] hIconOut
// Handle to the icon to show when the mouse is outside the button.
// Can be NULL.
// If this parameter is the special value BTNST_AUTO_GRAY the second
// icon will be automatically created starting from hIconIn and
// converted to grayscale.
// If this parameter is the special value BTNST_AUTO_DARKER the second
// icon will be automatically created 25% darker starting from hIconIn.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
//
DWORD SetIcon(HICON hIconIn, HICON hIconOut = NULL)
SetBitmaps
(使用资源)
- 为按钮分配位图
- 任何先前的图标或位图都将被删除
// Parameters:
// [IN] nBitmapIn
// ID number of the bitmap resource to show when the mouse is
// over the button.
// Pass NULL to remove any bitmap from the button.
// [IN] crTransColorIn
// Color (inside nBitmapIn) to be used as transparent color.
// [IN] nBitmapOut
// ID number of the bitmap resource to show when the mouse
// is outside the button.
// Can be NULL.
// [IN] crTransColorOut
// Color (inside nBitmapOut) to be used as transparent color.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
// BTNST_FAILEDMASK
// Failed creating mask bitmap.
//
DWORD SetBitmaps(int nBitmapIn, COLORREF crTransColorIn,
int nBitmapOut = NULL, COLORREF crTransColorOut = 0)
SetBitmaps
(使用句柄)
- 为按钮分配位图
- 任何先前的图标或位图都将被删除
// Parameters:
// [IN] hBitmapIn
// Handle fo the bitmap to show when the mouse is over the button.
// Pass NULL to remove any bitmap from the button.
// [IN] crTransColorIn
// Color (inside hBitmapIn) to be used as transparent color.
// [IN] hBitmapOut
// Handle to the bitmap to show when the mouse is outside the button.
// Can be NULL.
// [IN] crTransColorOut
// Color (inside hBitmapOut) to be used as transparent color.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
// BTNST_FAILEDMASK
// Failed creating mask bitmap.
//
DWORD SetBitmaps(HBITMAP hBitmapIn, COLORREF crTransColorIn,
HBITMAP hBitmapOut = NULL, COLORREF crTransColorOut = 0)
SetFlat
- 将按钮设置为标准样式或扁平化样式
// Parameters:
// [IN] bFlat
// If TRUE the button will have a flat style, else
// will have a standard style.
// By default, CButtonST buttons are flat.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD SetFlat(BOOL bFlat = TRUE, BOOL bRepaint = TRUE)
SetAlign
- 设置图标/位图与文本之间的对齐类型
// Parameters:
// [IN] byAlign
// Alignment type. Can be one of the following values:
// ST_ALIGN_HORIZ Icon/bitmap on the left, text on the right
// ST_ALIGN_VERT Icon/bitmap on the top, text on the bottom
// ST_ALIGN_HORIZ_RIGHT Icon/bitmap on the right, text on the left
// ST_ALIGN_OVERLAP Icon/bitmap on the same space as text
// By default, CButtonST buttons have ST_ALIGN_HORIZ alignment.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDALIGN
// Alignment type not supported.
//
DWORD SetAlign(BYTE byAlign, BOOL bRepaint = TRUE)
SetPressedStyle
- 设置按下样式
// Parameters:
// [IN] byStyle
// Pressed style. Can be one of the following values:
// BTNST_PRESSED_LEFTRIGHT Pressed style from left to right (as usual)
// BTNST_PRESSED_TOPBOTTOM Pressed style from top to bottom
// By default, CButtonST buttons have BTNST_PRESSED_LEFTRIGHT style.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDPRESSEDSTYLE
// Pressed style not supported.
//
DWORD SetPressedStyle(BYTE byStyle, BOOL bRepaint = TRUE)
SetCheck
- 设置
复选框
的状态 - 如果按钮不是
复选框
,此函数无意义
// Parameters:
// [IN] nCheck
// 1 to check the checkbox.
// 0 to un-check the checkbox.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD SetCheck(int nCheck, BOOL bRepaint = TRUE)
GetCheck
- 返回
复选框
的当前状态 - 如果按钮不是
复选框
,此函数无意义
// Return value:
// The current state of the checkbox.
// 1 if checked.
// 0 if not checked or the button is not a checkbox.
//
int GetCheck()
SetDefaultColors
- 将所有颜色设置为默认值。
// Parameters:
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD SetDefaultColors(BOOL bRepaint = TRUE)
SetColor
- 设置用于特定状态的颜色
// Parameters:
// [IN] byColorIndex
// Index of the color to set. Can be one of the following values:
// BTNST_COLOR_BK_IN Background color when mouse is over the button
// BTNST_COLOR_FG_IN Text color when mouse is over the button
// BTNST_COLOR_BK_OUT Background color when mouse is outside the button
// BTNST_COLOR_FG_OUT Text color when mouse is outside the button
// BTNST_COLOR_BK_FOCUS Background color when the button is focused
// BTNST_COLOR_FG_FOCUS Text color when the button is focused
// [IN] crColor
// New color.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDINDEX
// Invalid color index.
//
DWORD SetColor(BYTE byColorIndex, COLORREF crColor, BOOL bRepaint = TRUE)
GetColor
- 返回用于特定状态的颜色
// Parameters:
// [IN] byColorIndex
// Index of the color to get.
// See SetColor for the list of available colors.
// [OUT] crpColor
// A pointer to a COLORREF that will receive the color.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDINDEX
// Invalid color index.
//
DWORD GetColor(BYTE byColorIndex, COLORREF* crpColor)
OffsetColor
- 此函数应用于指定颜色的 RGB 分量。
- 此函数可以看作是一种简便的方法,可以使颜色比默认值更暗或更亮。
// Parameters:
// [IN] byColorIndex
// Index of the color to set.
// See SetColor for the list of available colors.
// [IN] shOffsetColor
// A short value indicating the offset to apply to the color.
// This value must be between -255 and 255.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDINDEX
// Invalid color index.
// BTNST_BADPARAM
// The specified offset is out of range.
//
DWORD OffsetColor(BYTE byColorIndex, short shOffset, BOOL bRepaint = TRUE)
SetAlwaysTrack
- 设置按钮的高亮显示逻辑
- 仅适用于扁平化按钮
// Parameters:
// [IN] bAlwaysTrack
// If TRUE the button will be highlighted even if the window that owns it, is
// not the active window.
// If FALSE the button will be highlighted only if the window that owns it,
// is the active window.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD SetAlwaysTrack(BOOL bAlwaysTrack = TRUE)
SetBtnCursor
- 设置鼠标悬停在按钮上时使用的光标
// Parameters:
// [IN] nCursorId
// ID number of the cursor resource.
// Pass NULL to remove a previously loaded cursor.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
//
DWORD SetBtnCursor(int nCursorId = NULL, BOOL bRepaint = TRUE)
DrawBorder
- 设置是否绘制按钮边框
- 仅适用于扁平化按钮
// Parameters:
// [IN] bDrawBorder
// If TRUE the border will be drawn.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD DrawBorder(BOOL bDrawBorder = TRUE, BOOL bRepaint = TRUE)
DrawFlatFocus
- 设置是否为扁平化按钮绘制焦点矩形
// Parameters:
// [IN] bDrawFlatFocus
// If TRUE the focus rectangle will be drawn also for flat buttons.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD DrawFlatFocus(BOOL bDrawFlatFocus, BOOL bRepaint = TRUE)
SetTooltipText
(使用资源)
- 设置要在按钮工具提示中显示文本
// Parameters:
// [IN] nText
// ID number of the string resource containing the text to show.
// [IN] bActivate
// If TRUE the tooltip will be created active.
//
void SetTooltipText(int nText, BOOL bActivate = TRUE)
SetTooltipText
- 设置要在按钮工具提示中显示文本
// Parameters:
// [IN] lpszText
// Pointer to a null-terminated string containing the text to show.
// [IN] bActivate
// If TRUE the tooltip will be created active.
//
void SetTooltipText(LPCTSTR lpszText, BOOL bActivate = TRUE)
EnableBalloonTooltip
- 启用使用气球样式显示的工具提示
- 在调用任何
SetTooltipText
之前必须调用此函数
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD EnableBalloonTooltip()
ActivateTooltip
- 启用或禁用按钮工具提示
// Parameters:
// [IN] bActivate
// If TRUE the tooltip will be activated.
//
void ActivateTooltip(BOOL bEnable = TRUE)
GetDefault
- 返回按钮是否为默认按钮
// Return value:
// TRUE
// The button is the default button.
// FALSE
// The button is not the default button.
//
BOOL GetDefault()
DrawTransparent
- 启用透明模式
- 注意:此操作不可逆。
DrawTransparent
应在按钮创建后立即调用。- 除非您真正需要(有位图背景),否则请勿使用透明按钮,因为每个透明按钮都会在其背景的内存中创建一个副本。
- 这可能会导致不必要的内存使用和执行开销。
// Parameters:
// [IN] bRepaint
// If TRUE the control will be repainted.
//
void DrawTransparent(BOOL bRepaint = FALSE)
SetURL
- 设置点击按钮时将打开的 URL。
// Parameters:
// [IN] lpszURL
// Pointer to a null-terminated string that contains the URL.
// Pass NULL to removed any previously specified URL.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD SetURL(LPCTSTR lpszURL = NULL)
SetMenu
- 将菜单与按钮关联
- 点击按钮将显示菜单
- 仅当未定义
BTNST_USE_BCMENU
时,此方法才可用
// Parameters:
// [IN] nMenu
// ID number of the menu resource.
// Pass NULL to remove any menu from the button.
// [IN] hParentWnd
// Handle to the window that owns the menu.
// This window receives all messages from the menu.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
//
DWORD SetMenu(UINT nMenu, HWND hParentWnd, BOOL bRepaint = TRUE)
SetMenu
- 将菜单与按钮关联
- 点击按钮将显示菜单。
- 仅当定义了
BTNST_USE_BCMENU
时,此方法才可用。菜单将由BCMenu
类处理。
// Parameters:
// [IN] nMenu
// ID number of the menu resource.
// Pass NULL to remove any menu from the button.
// [IN] hParentWnd
// Handle to the window that owns the menu.
// This window receives all messages from the menu.
// [IN] bWinXPStyle
// If TRUE the menu will be displayed using the new Windows XP style.
// If FALSE the menu will be displayed using the standard style.
// [IN] nToolbarID
// Resource ID of the toolbar to be associated to the menu.
// [IN] sizeToolbarIcon
// A CSize object indicating the size (in pixels) of each icon
// into the toolbar.
// All icons into the toolbar must have the same size.
// [IN] crToolbarBk
// A COLORREF value indicating the color to use as background
// for the icons into the toolbar.
// This color will be used as the "transparent" color.
// [IN] bRepaint
// If TRUE the control will be repainted.
//
// Return value:
// BTNST_OK
// Function executed successfully.
// BTNST_INVALIDRESOURCE
// Failed loading the specified resource.
//
DWORD SetMenu(UINT nMenu,
HWND hParentWnd,
BOOL bWinXPStyle = TRUE,
UINT nToolbarID = NULL,
CSize sizeToolbarIcon = CSize(16, 16),
COLORREF crToolbarBk = RGB(255, 0, 255),
BOOL bRepaint = TRUE)
SetMenuCallback
- 设置将在菜单显示之前发送到指定窗口的回调消息,该菜单与按钮关联
// Parameters:
// [IN] hWnd
// Handle of the window that will receive the callback message.
// Pass NULL to remove any previously specified callback message.
// [IN] nMessage
// Callback message to send to window.
// [IN] lParam
// A 32 bits user specified value that will be passed to the
// callback function.
//
// Remarks:
// the callback function must be in the form:
// LRESULT On_MenuCallback(WPARAM wParam, LPARAM lParam)
// Where:
// [IN] wParam
// If support for BCMenu is enabled: a pointer to BCMenu
// else a HMENU handle to the menu that is being to be
// displayed.
// [IN] lParam
// The 32 bits user specified value.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD SetMenuCallback(HWND hWnd, UINT nMessage, LPARAM lParam = 0)
SizeToContent
- 将按钮的大小调整为与图像相同
- 为了获得良好的效果,输入和输出图像应具有相同的大小
void SizeToContent()
SetSound
- 设置在特定按钮状态下必须播放的声音
- 仅当定义了
BTNST_USE_SOUND
时,此方法才可用
// Parameters:
// [IN] lpszSound
// A string that specifies the sound to play.
// If hMod is NULL this string is interpreted as a filename,
// else it is interpreted as a resource identifier.
// Pass NULL to remove any previously specified sound.
// [IN] hMod
// Handle to the executable file that contains the resource to
// be loaded.
// This parameter must be NULL unless lpszSound specifies a
// resource identifier.
// [IN] bPlayOnClick
// TRUE if the sound must be played when the button is clicked.
// FALSE if the sound must be played when the mouse is moved over
// the button.
// [IN] bPlayAsync
// TRUE if the sound must be played asynchronously.
// FALSE if the sound must be played synchronously. The
// application takes control after the sound is completely played.
//
// Return value:
// BTNST_OK
// Function executed successfully.
//
DWORD SetSound(LPCTSTR lpszSound,
HMODULE hMod = NULL,
BOOL bPlayOnClick = FALSE,
BOOL bPlayAsync = TRUE)
OnDrawBackground
- 每次需要绘制按钮背景时都会调用此函数。
- 如果按钮处于透明模式,此函数不会被调用。
- 这是一个虚函数,可以在
CButtonST
派生类中重写,以生成默认未提供的各种按钮。
// 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.
//
virtual DWORD OnDrawBackground(CDC* pDC, CRect* pRect)
OnDrawBorder
- 每次需要绘制按钮边框时都会调用此函数。
- 这是一个虚函数,可以在
CButtonST
派生类中重写,以生成默认未提供的各种按钮。
// 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.
//
virtual DWORD OnDrawBorder(CDC* pDC, CRect* pRect)
GetVersionI
- 以短数值形式返回类版本。
// Return value:
// Class version. Divide by 10 to get actual version.
//
static short GetVersionI()
GetVersionC
以 string
值形式返回类版本。
// Return value:
// Pointer to a null-terminated string containing the class version.
//
static LPCTSTR GetVersionC()
历史
- v3.9 (2003年3月3日)
- 增加了对 Windows XP 图标的支持
- 增加了对多尺寸图标的支持
- 为第二个图标添加了
BTNST_AUTO_DARKER
作为特殊值 - 修复了 Win9x/Me 下的灰度图标错误
- 类现在独立于
TTS_BALLOON
- v3.8 (2002年11月25日)
- 增加了对气球工具提示的支持
- 增加了
EnableBalloonTooltip
方法 OnDrawBorder
虚方法现在也为非扁平化按钮调用OnDrawBackground
和OnDrawBorder
现在接收正确的CRect*
参数- 修复了一个小的颜色错误
- 在 MFC 7.0 下正常工作
- v3.7 (2002年7月22日)
- 增加了
SetPressedStyle
方法 - 增加了
BTNST_INVALIDPRESSEDSTYLE
返回值 - 添加了
ST_ALIGN_OVERLAP
对齐样式
- 增加了
- v3.6 (2002年7月9日)
- 增加了
SetMenuCallback
方法,以便在菜单显示之前修改关联菜单 - 增加了基本声音支持
- 增加了
SetSound
方法 - 增加了
ResizeToContent
方法
- 增加了
- v3.5 (2002年4月18日)
- 第二个图标可以自动创建为灰度
- 为第二个图标添加了
BTNST_AUTO_GRAY
作为特殊值 - 如果按钮被禁用,则
Bitmap
显示为禁用状态 - 增加了属主绘制菜单支持(使用
BCMenu
类) - 添加了一个重载的
SetMenu
方法以支持BCMenu
类 - 增加了
OffsetColor
方法 - 增加了对
DDX_Check
调用的支持
- v3.4 (2001年10月17日)
- 增加了基本菜单支持
- 增加了
SetMenu
方法
- v3.3 (2001年9月20日)
- 默认按钮现在得到正确处理
- 删除了少数不常用的方法
- 其他优化
- v3.2 (2001年6月14日)
- 增加了位图支持
- 增加了
SetBitmaps
方法
- v2.6
- 添加了一个重载的
SetIcon
方法 - 在
SetAlign
函数中添加了ST_ALIGN_HORIZ_RIGHT
标志 - 修复了在 MFC 扩展 DLL 中使用时的错误
- 改进了透明按钮的代码
- 添加了一个重载的
- v2.5
- 支持 16x16、32x32 和 48x48 的图标
- 按钮可以动态创建
- 增加了透明按钮支持
- 自动检测默认按钮(仅对标准按钮有用)
- 自动检测图标尺寸
- 添加了
DrawTransparent
方法 - 添加了
GetDefault
方法 - 修改了
SetIcon
方法
- v2.4
- 增加了工具提示支持
- 添加了
SetTooltipText
、ActivateTooltip
成员 - “双击错误”应该已修复
- v2.3
- 该类现在应该可以在 DLL 中工作
- “空格键错误”应该已修复
- 在
SetIcon
成员的最后一行添加了RedrawWindow()
- 焦点矩形是最后绘制的内容
- 焦点矩形现在也可以为“扁平化”按钮绘制
- 添加了
SetFlatFocus
、GetFlatFocus
成员 - 添加了
SetBtnCursor
成员 - 扁平化按钮现在可以像 Internet Explorer 中那样工作
- v2.2
- 移除了
SubclassDlgItem
成员(这对用户是透明的) - 添加了
PreSubclassWindow
成员(这允许DDX_
调用) - 添加了
SetDefaultActiveFgColor
、SetActiveFgColor
、GetActiveFgColor
成员 - 添加了
SetDefaultActiveBgColor
、SetActiveBgColor
、GetActiveBgColor
成员 - 添加了
SetDefaultInactiveFgColor
、SetInactiveFgColor
、GetInactiveFgColor
成员 - 添加了
SetDefaultInactiveBgColor
、SetInactiveBgColor
、GetInactiveBgColor
成员 - 当鼠标悬停在按钮上时,焦点现在仍然保留在拥有它的控件上!
- 扁平化按钮现在也可以在非
CDialog
派生的窗口中正常工作! - 使用内存 DC(
CMemDC
)绘制按钮。这应该可以加快图形操作的速度。
- 移除了
- v2.1
- 支持两个图标
- 修改了
SetIcon
成员 - 添加了
SetShowText
/GetShowText
成员 - 修复了处理鼠标左键的错误
- 小优化
- v2.0
- 更改了类名以符合命名约定
- 支持 256 色图标
- 移除了一个愚蠢的内存泄漏!
- 移除了对
CImagelists
的支持 - HTML 格式的文档
- ST_CButton v1.1
- 一些小改动
- ST_CButton v1.0
- 首次发布
备注
演示应用程序展示了 CButtonST
类的几乎所有功能。
CButtonST
的架构使其能够生成默认未提供的各种按钮。如果有人实现了新的按钮样式,我很乐意将其代码包含在下一个 CButtonST
演示应用程序中。
谢谢
非常感谢数十位在他们的应用程序中使用 CButtonST
的用户。
也感谢所有发现并修复 bug 的人。谢谢!
如果可能,请发送一张您应用程序中使用 CButtonST
的截图。这些截图将收集起来供个人参考。
免责声明
本软件及随附文件按“原样”分发,不附带任何明示或暗示的保证。不对可能的损害或功能承担任何责任。用户在使用本软件时必须承担全部风险。
许可证
本文档没有明确的许可证,但可能包含文章文本或下载文件本身的使用条款。如有疑问,请通过下方的讨论区联系作者。
作者可能使用的许可证列表可以在此处找到。