动态弹出tip窗口

它能够实现:动态弹出tip窗口,这个窗口能够显示一个icon和多行文本。文本以'/n'分行,窗口的颜色来源于系统窗口,窗口文本,和滚动条颜色。


通过调用Create()方法创建tip窗口
调用Show()方法显示即时tips
调用SetIcon()来设置即时tips的图标
RelayEvent()必须被父窗口的PreTranslateMessage()方法调用
SetShowDelay()用来调整tip弹出的延时时间
SetFont()用来改变tooltip的字体,默认为系统的GUI字体

class CXInfoTip : public CWnd
{
protected:
///
// Tool information structure
///
typedef struct
{
CString szText; // Tooltip text
HICON hIcon; // Tooltip icon
} TipToolInfo;

// Timer identifiers
enum
{
timerShow = 100, // Show timer
timerHide = 101 // Hide timer
};

LPCTSTR m_szClass; // Window class

int m_nShowDelay; // Show delay

CPoint m_ptOrigin; // Popup origin

CString m_szText; // Tip text

UINT m_nTimer; // Show/hide timer

HICON m_hIcon; // Tip icon
CSize m_IconSize; // Tip icon size

CFont *m_pFont; // Tip font

CMap<HWND, HWND, TipToolInfo, TipToolInfo> m_ToolMap; // Tools map

public:
CXInfoTip();
virtual ~CXInfoTip();

BOOL Create(CWnd *parent);

void AddTool(CWnd *pWnd, LPCTSTR szTooltipText, HICON hIcon = NULL);
void RemoveTool(CWnd *pWnd);

void Show(CString szText, CPoint *pt = NULL);
void Hide() { ShowWindow(SW_HIDE); };

// Sets the delay for the tooltip
void SetShowDelay(int nDelay) { m_nShowDelay = nDelay; };

void SetIcon(HICON hIcon);

// Sets the tooltip font
void SetFont(CFont *pFont)
{
m_pFont = pFont;
if (IsWindow(m_hWnd))
RedrawWindow();
};

void RelayEvent(LPMSG lpMsg);

protected:
BOOL GetWindowRegion(CDC *pDC, HRGN* hRegion, CSize* Size = NULL);


protected:
//{{AFX_MSG(CXInfoTip)
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

};  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值