📄 chameleonctl.h
字号:
#if !defined(AFX_CHAMELEONCTL_H__2E1BDC1A_34B2_45FB_A4EA_912BCA97F3E5__INCLUDED_)
#define AFX_CHAMELEONCTL_H__2E1BDC1A_34B2_45FB_A4EA_912BCA97F3E5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ChameleonCtl.h : Declaration of the CChameleonCtrl ActiveX Control class.
/////////////////////////////////////////////////////////////////////////////
// CChameleonCtrl : See ChameleonCtl.cpp for implementation.
class CChameleonCtrl : public COleControl
{
DECLARE_DYNCREATE(CChameleonCtrl)
// Constructor
public:
CChameleonCtrl();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChameleonCtrl)
public:
virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
virtual void DoPropExchange(CPropExchange* pPX);
virtual void OnResetState();
//}}AFX_VIRTUAL
// Implementation
protected:
~CChameleonCtrl();
DECLARE_OLECREATE_EX(CChameleonCtrl) // Class factory and guid
DECLARE_OLETYPELIB(CChameleonCtrl) // GetTypeInfo
DECLARE_PROPPAGEIDS(CChameleonCtrl) // Property page IDs
DECLARE_OLECTLTYPE(CChameleonCtrl) // Type name and misc status
// Message maps
//{{AFX_MSG(CChameleonCtrl)
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Dispatch maps
//{{AFX_DISPATCH(CChameleonCtrl)
afx_msg long GetMousePointer();
afx_msg void SetMousePointer(long nNewValue);
afx_msg LPPICTUREDISP GetMouseIcon();
afx_msg void SetMouseIcon(LPPICTUREDISP newValue);
afx_msg LPPICTUREDISP GetPicture();
afx_msg void SetPicture(LPPICTUREDISP newValue);
afx_msg long GetButtonType();
afx_msg void SetButtonType(long nNewValue);
afx_msg long GetColorScheme();
afx_msg void SetColorScheme(long nNewValue);
afx_msg BOOL GetPress();
afx_msg void SetPress(BOOL bNewValue);
afx_msg BOOL GetShowFocusRect();
afx_msg void SetShowFocusRect(BOOL bNewValue);
afx_msg BOOL GetStretch();
afx_msg void SetStretch(BOOL bNewValue);
afx_msg BSTR GetToolTipText();
afx_msg void SetToolTipText(LPCTSTR lpszNewValue);
afx_msg OLE_COLOR GetBackOverColor();
afx_msg void SetBackOverColor(OLE_COLOR nNewValue);
afx_msg OLE_COLOR GetForeOverColor();
afx_msg void SetForeOverColor(OLE_COLOR nNewValue);
afx_msg long GetTextEffect();
afx_msg void SetTextEffect(long nNewValue);
afx_msg BOOL GetHandPointer();
afx_msg void SetHandPointer(BOOL bNewValue);
afx_msg LPPICTUREDISP GetDownPicture();
afx_msg void SetDownPicture(LPPICTUREDISP newValue);
afx_msg LPPICTUREDISP GetOverPicture();
afx_msg void SetOverPicture(LPPICTUREDISP newValue);
afx_msg LPPICTUREDISP GetDisablePicture();
afx_msg void SetDisablePicture(LPPICTUREDISP newValue);
afx_msg long GetAcceleratKey();
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
virtual void OnBackColorChanged();
virtual void OnForeColorChanged();
virtual void OnTextChanged();
virtual void OnEnabledChanged();
virtual void OnFontChanged();
afx_msg void AboutBox();
// Event maps
//{{AFX_EVENT(CChameleonCtrl)
void FireMouseOver()
{FireEvent(eventidMouseOver,EVENT_PARAM(VTS_NONE));}
void FireMouseOut()
{FireEvent(eventidMouseOut,EVENT_PARAM(VTS_NONE));}
//}}AFX_EVENT
DECLARE_EVENT_MAP()
// Dispatch and event IDs
public:
enum {
//{{AFX_DISP_ID(CChameleonCtrl)
dispidMousePointer = 1L,
dispidMouseIcon = 2L,
dispidPicture = 3L,
dispidButtonType = 4L,
dispidColorScheme = 5L,
dispidPress = 6L,
dispidShowFocusRect = 7L,
dispidStretch = 8L,
dispidToolTipText = 9L,
dispidBackOverColor = 10L,
dispidForeOverColor = 11L,
dispidTextEffect = 12L,
dispidHandPointer = 13L,
dispidDownPicture = 14L,
dispidOverPicture = 15L,
dispidDisablePicture = 16L,
dispidAcceleratKey = 17L,
eventidMouseOver = 1L,
eventidMouseOut = 2L,
//}}AFX_DISP_ID
};
protected:
/////////////////////////////////////////////////////////////////////////////
//成员函数
//
//重绘函数
int Redraw( int nStatus, bool bForce, CDC * pdcDraw = NULL);
//检查鼠标是否在控件上
bool CheckMouseOver();
//创建控件区域
int MakeRegion( CRgn & rgnCreate );
//设置窗口颜色变量
int SetColor();
//增减RBG颜色值
DWORD ShiftColor( DWORD ulColor, int nValue, bool m_bXP = false );
//XP风格的增减RGB颜色值
DWORD ShiftColorOXP( DWORD ulColor, int nBase = 0xB0 );
//画文本
int DrawCaption( HDC hdcCtrl, int nDrawType );
//画文本的特效
int DrawEffect( HDC hdcCtrl, CRect recDraw );
//画长方形
int DrawRectangle( HDC hdcCtrl, int nLeft, int nTop, int nWidth, int nHeight, DWORD ulColor, bool bBoard = false );
//画边框
int DrawFrame( HDC hdcCtrl, DWORD ulHigh, DWORD ulDark, DWORD ulLight, DWORD ulShadow, int nExtraOffset, bool bFlat = false );
//画焦点框
int DrawFocusR( HDC hdcCtrl, CRect recFocus, DWORD ulColor );
//画线
int DrawLine( HDC hdcCtrl, int nX1, int nY1, int nX2, int nY2, DWORD ulColor );
//向ToolTipCtrl发送消息
void RelayEvent(UINT message, WPARAM wParam, LPARAM lParam);
//设置鼠标
int SetMoveCursor( long lMousePointer );
//恢复鼠标
int RestoreCursor();
//获得图片高宽
int GetPictureSize( int nType, int &nWidth, int &nHeight );
/////////////////////////////////////////////////////////////////////////////
//属性变量
//
//鼠标类型(未使用)
long m_lMousePointer;
//m_lMousePointer为99(自定义)时的鼠标(未使用)
CPictureHolder m_phdMouseIcon;
//当按钮类型为Graphic时,正常状态图片
CPictureHolder m_phdPicture;
//按钮类型
//Windows16 = 1,
//Windows32 = 2,
//WindowsXP = 3,
//Mac = 4,
//Java = 5,
//Netscape6 = 6,
//SimpleFlat = 7,
//FlatHight= 8,
//OfficeXP= 9,
//Transparent= 10,
//Hover= 11,
//KDE2= 12,
//Graphic = 13
long m_lButtonType;
//按钮颜色方案
//UseWindows = 1,
//Custom = 2,
//ForceStandard = 3,
//UseContainer = 4
long m_lColorScheme;
//是否为CheckBox行为风格按扭
BOOL m_bPress;
//是否显示焦点框
BOOL m_bShowFocusRect;
//是否扩充图片至按钮当前大小
BOOL m_bStretch;
//工具提示文本
CString m_strTipText;
//鼠标移动在按钮上时的背景颜色
long m_lBackOverColor;
//鼠标移动在按钮上时的前景颜色
long m_lForeOverColor;
//按钮文字效果
//None = 0,
//Embossed = 1,
//Engraved = 2,
//Shadowed = 3
long m_lTextEffect;
//鼠标移动在按钮上时,是否将光标改为一只手
BOOL m_bHandPointer;
//当按钮类型为Graphic时,按下状态图片
CPictureHolder m_phdDownPicture;
//当按钮类型为Graphic时,鼠标移动状态图片
CPictureHolder m_phdOverPicture;
//当按钮类型为Graphic时,不可用状态图片
CPictureHolder m_phdDisablePicture;
/////////////////////////////////////////////////////////////////////////////
//状态变量
//
//快捷键
BYTE m_ucAccessKey;
//鼠标移动在控件上面的标志
bool m_bMouseOver;
//当前鼠标类型
long m_lCursorType;
//移动在按钮上面之前的鼠标
HCURSOR m_hPrevCursor;
//鼠标双击
bool m_bMouseDBClk;
//键盘按下的键
int m_nLastKey;
//如果Press属性为true,当前是否处于Press状态
bool m_bPressState;
//当前焦点状态
bool m_bFocus;
//当前按钮状态:0,正常;1,按下
int m_nStatus;
//当前显示的文字
CString m_strText;
//当前文字的显示位置和大小
CRect m_recText;
//按钮的高度和宽度
int m_nWidth;
int m_nHeight;
//焦点框
CRect m_recFocusRect;
//窗口区域
CRgn m_rgnControl;
//各种颜色
DWORD m_ulFace;
DWORD m_ulFaceO;
DWORD m_ulText;
DWORD m_ulTextO;
DWORD m_ulShadow;
DWORD m_ulLight;
DWORD m_ulHighLight;
DWORD m_ulDarkShadow;
DWORD m_ulXPFace;
DWORD m_ulOfficeXPB;
DWORD m_ulOfficeXPF;
//工具提示功能对象
CToolTipCtrl m_ttpMes;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHAMELEONCTL_H__2E1BDC1A_34B2_45FB_A4EA_912BCA97F3E5__INCLUDED)
/*
/////////////////////////////////////////////////////////////////////////////
//未使用的属性枚举变量
//
typedef [uuid(55A57721-6744-49d2-A711-01E12E6CC023), version(1.0)]
enum ButtonTypes{
Windows16 = 1,
Windows32 = 2,
WindowsXP = 3,
Mac = 4,
Java = 5,
Netscape6 = 6,
SimpleFlat = 7,
FlatHight= 8,
OfficeXP= 9,
Transparent= 10,
Hover= 11,
KDE2= 12,
Graphic = 13
} ButtonTypes;
typedef [uuid(7D7C39D1-5479-4650-937A-768645B2634A), version(1.0)]
enum ColorTypes{
UseWindows = 1,
Custom = 2,
ForceStandard = 3,
UseContainer = 4
} ColorTypes;
typedef [uuid(9CE8E7E4-134F-4950-819B-2208193A3F8B), version(1.0)]
enum EffectTypes{
None = 0,
Embossed = 1,
Engraved = 2,
Shadowed = 3
} EffectTypes;
MousePointer:
Default 0 (默认值)由对象决定的形状。
Arrow 1 箭头。
Cross 2 十字(十字型指针)
IBeam 3 I 型标。
Icon 4 图标(在方块中的小方块)。
Size 5 大小(四向箭头指向上下左右)。
SizeNESW 6 右上 - 左下大小(双向箭头分别指向右上和左下)。
SizeNS 7 垂直大小(双向箭头分别指向上和下)。
SizeNWSE 8 左上 - 右下大小。
SizeEW 9 水平大小(双向箭头分别指向左和右)。
UpArrow 10 向上箭头键。
Hourglass 11 沙漏(等待)。
NoDrop 12 不允许放下。
ArrowHourglass 13 箭头和沙漏。
ArrowQuestion 14 箭头和问号。
SizeAll 15 四向箭头。
Custom 99 由 MouseIcon 属性指定的自定义图标。
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -