typedef struct tagCtrlNodeInfo
{
struct tagCtrlNodeInfo *pNext;
int nCtrlType; //控件的类型,是 按钮,进度条,还是其他...
RECT hitrc; //控件的坐在位置,这个CYasSuperList用来响应相关的消息,比如是否点中这个控件,或者鼠标移到这控件。
pLGCallBack pfnCallBack; //控件的响应函数,一般是用于注册的。
int MouseState; //本控件的鼠标状态,是离开了,还是处于HOVER状态。
PVOID pData; //详细的描述了控件的信息。
}CtrlNodeInfo, *pCtrlNodeInfo;
因为不同控件需要的描述的信息不一样,所在tagCtrlNodeInfo的字段PVOID pData;的意义就是用于描述具体的控件。
比如它可能指向下面这么一个结构:
typedef struct tagCheckBoxData
{
POINT pos;
int nCtrlId;
RECT hitrc;
pLGCallBack pfnCallBack;
HCURSOR hMoveCursor;
BOOL bCheck;
int nLen;
}CheckBoxData, *pCheckBoxData;
3 控件的添加:
目前CYasSuperList 支持的控件类型有
位图, 按钮, Checkbox, 直线, 文字, 图标, 进度条 和 动态的GIF图片。
相关接口有:
LISTITEM_NORMAL 系列的有:
int CListAddCtrl_Button(int iItem, int iSubItem, POINT &pos, int len,
int hei, int iState, COLORREF bkColor, BOOL bFr,
pLGCallBack pfnCallBack);
int CListAddCtrl_Button(int iItem, int iSubItem, POINT &pos, int len,
int hei, int iState, COLORREF bkColor, BOOL bFr,
CFont *ptextfont, LPSTR pszText, COLORREF bkTextColor,
pLGCallBack pfnCallBack);
int CListAddCtrl_CheckBox(int iItem, int iSubItem, POINT &pos, BOOL bCheck,
int nLen, pLGCallBack pfnCallBack);
int CListAddCtrl_Progress(int iItem, int iSubItem, POINT &pos, int len, int hei,
int percent, COLORREF col, int index_type, pLGCallBack
pfnCallBack);
int CListAddCtrl_Bitmap(int iItem, int iSubItem, POINT &pos,
int nBitmapId,pLGCallBack pfnCallBack);
int CListAddCtrl_Text(int iItem, int iSubItem, POINT &pos, CFont *pfont,
LPSTR psztext, COLORREF TextColor, int
state, BOOL bxButonText,
pLGCallBack pfnCallBack);
int CListAddCtrl_Icon(int iItem, int iSubItem, POINT &pos,
PVOID pdata, int type_index, pLGCallBack
int CListAddVirtualCtrl_Text(int iParentItem, int iItem, int iSubItem, POINT &pos,
CFont *pfont, LPSTR psztext, COLORREF TextColor, int state,
BOOL bxButonText,pLGCallBack pfnCallBack);
int CListAddVirtualCtrl_Bitmap(int iParentItem, int nChildItem, int iSubItem, POINT &pos,
int nBitmapId,pLGCallBack pfnCallBack);
int CListAddVirtualCtrl_CheckBox(int iParentItem, int nChildItem, int iSubItem, POINT &pos,
BOOL bCheck, int nLen, pLGCallBack
pfnCallBack);
int CListAddVirtualCtrl_Progress(int iParentItem, int nChildItem, int iSubItem, POINT &pos, int len, int
hei,
int percent, COLORREF col, int index_type, pLGCallBack pfnCallBack);
int CListAddVirtualCtrl_Icon(int iParentItem, int nChildItem, int iSubItem, POINT &pos,
PVOID pdata, int type_index, pLGCallBack
pfnCallBack);
int CListAddVirtualCtrl_Button(int iParentItem, int nChildItem, int iSubItem,POINT &pos,
int len, int hei, int iState, COLORREF bkColor, BOOL bFr,
CFont *ptextfont, LPSTR pszText, COLORREF bkTextColor,
pLGCallBack pfnCallBack);
int CListAddVirtualCtrl_Button(int iParentItem, int nChildItem, int iSubItem, POINT &pos, int len,
int hei, int iState, COLORREF bkColor, BOOL bFr,
pLGCallBack pfnCallBack);
4 控件的绘画:
难于描述,,,直接上图,绘画的代码为了方便扩展和管理,我把他放在一个全局文件里
GDrawManger.cpp,这里提供了各种控件的绘画,控件可以根据自己的需求来画
BOOL __DrawIcon0( __in CDC *pdc,
__in POINT &point,
__out RECT &rc,
__in int nIconId);
BOOL __DrawIcon1( __in CDC *pdc,
__in POINT &point,
__out RECT &rc,
__in HICON hIcon );
BOOL __DrawIcon2( __in CDC *pdc,
__in POINT &point,
__out RECT &rc,
__in LPCTSTR lpIconPath );
BOOL __DrawIcon3( __in CDC *pdc,
__in POINT &point,
__out RECT &rc,
__in LPCTSTR lpszName );
void __DrawBmp0(CDC *pdc, POINT &Pos, int nBitmapId, RECT &rc);
void __DrawButton(__in CDC *pdc, __in POINT &point, __in __out RECT &rc,
__in int len, __in int hei, __in BOOL bFr, __in COLORREF col, __in int nState);
void __DrawButtonEx(__in CDC *pdc,
__in POINT &point,
__in __out RECT &rc,
__in int len,
__in int hei,
__in BOOL bFr,
__in COLORREF col,
__in int nState,
__in CFont *ptextfont,
__in LPSTR pszText,
__in COLORREF bkTextColor);
void __DrawProgress1(__in CDC *pdc, __in POINT &point,
__in __out RECT &rc, __in int len, __in int hei, __in COLORREF col);
void __DrawProgress0(__in CDC *pdc, __in POINT &point, __in __out RECT &rc,
__in int len, __in int hei, __in int Pos, __in COLORREF col);
void __DrawText(__in CDC *pdc, __in POINT &point, __in __out RECT &rc,
__in CFont *pfont, LPSTR psztext, COLORREF TextColor);
void __DrawCheckBox(__in CDC *pdc, __in POINT &point, __out RECT &rc, __in BOOL bCheck, __in int nLen);