?? xinfotip.h
字號:
/********************************************************************************
類名:CXInfoTip
功能:建立一立體感的,可以帶圖標(biāo)并多行顯示的工具提示條
用法:
1、在StdAfx.h頭文件中,加入下面頭文件
#include <afxtempl.h>
2、包含狀態(tài)條彈出窗口的頭文件
#include "XInfoTip.h"
3、在類變量中定義其變量
CXInfoTip m_Tip; //工具提示變量
HICON m_hIcon1; //其上顯示的圖標(biāo)
4、可在窗體初始化(如:OnInitDialog)中加入下面代碼既可
m_hIcon1 = (HICON)::LoadImage(AfxFindResourceHandle(MAKEINTRESOURCE(IDI_ICON1), RT_GROUP_ICON), MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 0, 0, 0);
// 創(chuàng)建工具提示
m_Tip.Create(this);
// 和相應(yīng)控件產(chǎn)生聯(lián)系
m_Tip.AddTool(GetDlgItem(IDOK), _T("This is the OK button!\nPress it to close the dialog..."), m_hIcon1);
5、在窗體退出(如:OnDestroy() )時,消毀原分配的圖標(biāo)變量
::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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -