⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xinfotip.h

📁 visual c++ 实例编程
💻 H
字号:

/********************************************************************************
类名:CXInfoTip
功能:建立一立体感的,可以带图标并多行显示的工具提示条
用法:
  1、在StdAfx.h头文件中,加入下面头文件
     #include <afxtempl.h>
  2、包含状态条弹出窗口的头文件
     #include "XInfoTip.h"
  3、在类变量中定义其变量
     CXInfoTip		m_Tip;     //工具提示变量
  	 HICON			m_hIcon1;  //其上显示的图标
  4、可在窗体初始化(如:OnInitDialog)中加入下面代码既可
    m_hIcon1 = (HICON)::LoadImage(AfxFindResourceHandle(MAKEINTRESOURCE(IDI_ICON1), RT_GROUP_ICON), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, 0);

	// 创建工具提示
	m_Tip.Create(this);

	// 和相应控件产生联系
	m_Tip.AddTool(GetDlgItem(IDOK), _T("This is the OK button!\nPress it to close the dialog..."), m_hIcon1);
  5、在窗体退出(如:OnDestroy() )时,消毁原分配的图标变量
    ::DestroyIcon(m_hIcon1);
修改人:徐景周(jingzhou_xu@163.net)
组织:未来工作室(Future Studio)
日期:2001.12.1
*********************************************************************************/
#ifndef _XPOPUPTIP_H_INCLUDE_
#define _XPOPUPTIP_H_INCLUDE_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

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()

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -