栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

VC++中HTControl的CHTButton按钮控件类用法实例解析

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

VC++中HTControl的CHTButton按钮控件类用法实例解析

本文以实例形式讲解了VC++中HTControl控件类的CHTButton按钮控件类用法,相信对大家更好的理解VC++有一定的帮助。具体内容如下:

一般了解VC++的朋友都知道,VC++ 按钮控件CHTButton隶属HTControl控件组,直接由WIN32 API实现,你可以在SDK,MFC,wxWidget等环境下使用它。支持生成各种类型的按钮,比如:普通按钮,PNG透明按钮,复选框按钮,单选按钮等。使用时请注意,窗体必须动态创建,代码段如下:

m_HTBtnClose.Create(758, 0, 39, 20, m_hWnd, iChildId++);
m_HTBtnClose.SetAllBitmap(m_hBmpBtnCloseNormal, m_hBmpBtnCloseDown,m_hBmpBtnCloseHover);
m_HTBtnClose.SetParentBgMemDC(m_hdcMemBuf);

CHTButton.h控件核心代码及注释说明如下:


#if !defined(__CHTBUTTON_H__)
#define __CHTBUTTON_H__
#include "CHTTip.h"
class CMyButton;
class AFX_CLASS_EXPORT CHTButton
{
public:
 CHTButton();
 ~CHTButton();


 HWND Create(int x, int y, int iWidth, int iHeight, HWND hParent, int iBtnId, 
     TCHAR* szLabel = NULL, DWORD dwStyle = NULL);


 void MoveWindow(int x, int y, int iWidth = -1, int iHeight = -1, BOOL bRepaint = TRUE);


 void SetToolTip(CHTTip* pclTip);


 void SetTipText(TCHAR* szTipText);


 HWND GetHandle();


 HWND GetParent();


 void SetFont(HFONT hFont);


 void SetBtnTextColor(COLORREF CRText);


 void SetHoverFont(HFONT hFont);


 void SetHoverBtnTextColor(COLORREF CRText);


 void Disable();


 void Enable();


 void SetLabel(TCHAR* szLabel, POINT* point = NULL, BOOL bTextMove = TRUE);


 TCHAR* GetLabel();


 int GetState();


 void SetLongPressTime(WORD wLongPressTime);


 void SetCheck(BOOL bCheck);


 BOOL GetCheck();


 void SetNormalBitmap(HBITMAP hBitmap, int iNormalLeftLen = 0, int iNormalRightLen = 0);


 void SetLBtnDownBitmap(HBITMAP hBitmap);


 void SetHoverBitmap(HBITMAP hBitmap);


 void SetDisableBitmap(HBITMAP hBitmap);

 void SetAllBitmap(HBITMAP hBitmapNormal, HBITMAP hBitmapLBtnDown, HBITMAP hBitmapHover,
 int iNormalLeftLen = 0, int iNormalRightLen = 0);


 void SetIcon(HBITMAP hBitmap, RECT* pIconRect);


 void SetTransparency(int iTransparency);
 

 void SetParentBgMemDC(HDC hParentBgMemDC, int x = 0, int y = 0);
 

 void SetParentBgBitmap(HBITMAP hParentBgBitmap, int x = 0, int y = 0);
 

 void SetParentBgColor(COLORREF CRParentBg = RGB(236, 233, 216));


 void DrawWindow(HDC hdcDest, int x = 0, int y = 0);

 CMyButton* GetCMyButton();

private:
 CMyButton* m_pclBtn;
};
#endif //!__CHTBUTTON_H__

此类支持窗体以任意透明度显示,操作很简单,使用下面接口即可实现:

void SetTransparency(int iTransparency);

CHTButton类同时也实现了PNG透明按钮,感兴趣的读者可以自己测试一下。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/65586.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号