轻松实现非客户区按钮
2010-09-04 20:48:21 来源:WEB开发网二、使用
2.1 首先我们需要引用两个类的头文件
#include "NCButtonManager.h"
#include "NCButton.h"
2.2 为按钮定义ID
#define ID_BUTTON1 100
#define ID_BUTTON2 101
#define ID_BUTTON3 102
2.3 添加按钮和管理类成员变量
// Implementation
public:
CNCButton m_NcButton1;
CNCButton m_NcButton2;
CNCButton m_NcButton3;
CNCButtonManager m_NcButtonManager;
2.4 创建按钮
// 按钮的位置和尺寸
POINT ptBtn1Offset = {120, 10};
POINT ptBtn2Offset = {20, 32};
POINT ptBtn3Offset = {190, 10};
SIZE sizeBtn1 = {60, 14};
SIZE sizeBtn2 = {16, 14};
SIZE sizeBtn3 = {16, 14};
// 创建按钮
m_NcButton1.Create("", this->m_hWnd, ptBtn1Offset, sizeBtn1, ID_BUTTON1);
m_NcButton2.Create("", this->m_hWnd, ptBtn2Offset, sizeBtn2, ID_BUTTON2);
m_NcButton3.Create("", this->m_hWnd, ptBtn3Offset, sizeBtn3, ID_BUTTON3);
// 设置文字、提示、按钮位图
m_NcButton1.SetText("VC知识库", "宋体", 12);
m_NcButton1.SetTooltip("VC知识库欢迎您!");
m_NcButton2.SetButtonBitmap(IDB_PEN1, BTNBMP_NORMAL); // 正常位图
m_NcButton2.SetButtonBitmap(IDB_PEN2, BTNBMP_MOUSEOVER); // 鼠标移到上面时的位图
m_NcButton2.SetTooltip("pen");
m_NcButton3.SetButtonBitmap(IDB_PEN1, BTNBMP_NORMAL);
m_NcButton3.SetButtonBitmap(IDB_PEN2, BTNBMP_MOUSEOVER);
m_NcButton3.SetTooltip("pen");
// 添加到管理类
m_NcButtonManager.AddButton(&m_NcButton1);
m_NcButtonManager.AddButton(&m_NcButton2);
m_NcButtonManager.AddButton(&m_NcButton3);
更多精彩
赞助商链接