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

📄 pptooltip.h

📁 这是一个比较好的实现较理想的界面的例子
💻 H
📖 第 1 页 / 共 2 页
字号:
	CImageList m_imgTooltip; //the image list 
	CSize m_szImage;

	PPTOOLTIP_INFO m_pToolInfo; //info of the current tooltip

#ifdef PPTOOLTIP_USE_SHADE
	void SetShade(CRect rect, UINT shadeID = 0, BYTE granularity = 8, BYTE coloring = 0, COLORREF color = 0);
	CCeXDib m_dNormal,m_dh,m_dv;
#endif


// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPPToolTip)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

// Implementation
public:
	//Functions for the styles
	void  SetStyles(DWORD nStyles, int nIndexTool = PPTOOLTIP_TOOL_NOEXIST); //Sets New Style
	void  ModifyStyles(DWORD nAddStyles, DWORD nRemoveStyles, int nIndexTool = PPTOOLTIP_TOOL_NOEXIST); //Modifies styles
	DWORD GetStyles(int nIndexTool = PPTOOLTIP_TOOL_NOEXIST); //Gets current Styles
	void  SetDefaultStyles(int nIndexTool = PPTOOLTIP_TOOL_NOEXIST); //Sets default styles

	//functions for color
	void SetColor(int nIndex, COLORREF crColor); //Sets the color
	COLORREF GetColor(int nIndex); //Gets the color
	void SetDefaultColors(); //Sets default colors
	void SetGradientColors(COLORREF crBegin, COLORREF crMid, COLORREF crEnd, int nIndexTool = PPTOOLTIP_TOOL_NOEXIST); //Sets the gradient's colors
	void GetGradientColors(COLORREF & crBegin, COLORREF & crMid, COLORREF & crEnd, int nIndexTool = PPTOOLTIP_TOOL_NOEXIST); //Gets the gradient's colors

	//functions for tool
	void AddTool(CWnd * pWnd, UINT nIdText, HICON hIcon = NULL, LPCRECT lpRectTool = NULL, UINT nIDTool = 0); //Adds tool
	void AddTool(CWnd * pWnd, UINT nIdText, UINT nIdIcon, CSize szIcon = CSize(0, 0), LPCRECT lpRectTool = NULL, UINT nIDTool = 0); //Adds tool
	void AddTool(CWnd * pWnd, CString sTooltipText, HICON hIcon = NULL, LPCRECT lpRectTool = NULL, UINT nIDTool = 0); //Adds tool
	void AddTool(CWnd * pWnd, CString sTooltipText, UINT nIdIcon, CSize szIcon = CSize(0, 0), LPCRECT lpRectTool = NULL, UINT nIDTool = 0); //Adds tool
	void AddTool(PPTOOLTIP_INFO ti); //Adds tool
	int  FindTool(CPoint & pt);
	int  FindTool(CWnd * pWnd, LPCRECT lpRect = NULL);
	int  FindTool(UINT nIDTool);
	BOOL GetTool(int nIndexTool, PPTOOLTIP_INFO & ti);
	BOOL RemoveTool(int nIndexTool);  //Removes specified tool
	void RemoveAllTools(); // Removes all tools
	BOOL IsExistTool(int nIndexTool);
	void SetAtTool(int nIndexTool, PPTOOLTIP_INFO & ti);

	//Functions for resources name
	void AddNameOfResource(CString sName, UINT nID, BYTE nTypeRes = TYPE_RES_MASK_BITMAP, COLORREF crMask = RGB(255, 0, 255));
	int  FindIdOfResource(CString sName);
	int  FindNameOfResource(UINT nID);
	void RemoveNameOfResource(int nIndex);
	void RemoveAllNamesOfResource();

	//Functions for images
	void SetImageList(UINT nIdBitmap, int cx, int cy, int nCount, COLORREF crMask = RGB(255, 0, 255));
	void SetImageList(HBITMAP hBitmap, int cx, int cy, int nCount, COLORREF crMask = RGB(255, 0, 255));
	CImageList * GetImageList(CSize & sz);

	//Functions for mask
	void  SetMaskTool(int nIndexTool, UINT nMask = 0);
	void  ModifyMaskTool(int nIndexTool, UINT nAddMask, UINT nRemoveMask);
	UINT  GetMaskTool(int nIndexTool);

	//functions for effects
	void SetEffectBk(UINT nEffect, BYTE nGranularity = 2, int nIndexTool = PPTOOLTIP_TOOL_NOEXIST);
	UINT GetEffectBk(int nIndexTool = PPTOOLTIP_TOOL_NOEXIST);
	UINT GetEffectBk(BYTE & nGranularity, int nIndexTool = PPTOOLTIP_TOOL_NOEXIST);

	//functions for
	void  SetNotify(HWND hWnd);
	void  SetNotify(BOOL bParentNotify = TRUE);
	BOOL  GetNotify(); //Is enabled notification

	//functions for delay
	void SetDelayTime(DWORD dwDuration, UINT nTime);
	UINT GetDelayTime(DWORD dwDuration) const;

	//functions for sizes
	void SetSize(int nSizeIndex, UINT nValue);
	UINT GetSize(int nSizeIndex);
	void SetDefaultSizes(BOOL bBalloonSize = TRUE);

	//functions for direction
	void SetDirection(UINT nDirection = PPTOOLTIP_RIGHT_BOTTOM, int nIndex = PPTOOLTIP_TOOL_NOEXIST);
	UINT GetDirection(int nIndexTool = PPTOOLTIP_TOOL_NOEXIST);

	// 
	void SetBehaviour(UINT nBehaviour = 0, int nIndexTool = PPTOOLTIP_TOOL_NOEXIST);
	UINT GetBehaviour(int nIndexTool = PPTOOLTIP_TOOL_NOEXIST);
//	void SetMultipleShow(BOOL bMultiple = TRUE, CWnd * pWnd = NULL);
//	BOOL IsMultipleShow(CWnd * pWnd = NULL);

	//Functions for the fonts
	BOOL  SetFont(CFont & font); //set font
	BOOL  SetFont(LPLOGFONT lf); //set font
	BOOL  SetFont(LPCTSTR lpszFaceName, int nSizePoints = 8,
									BOOL bUnderline = FALSE, BOOL bBold = FALSE,
									BOOL bStrikeOut = FALSE, BOOL bItalic = FALSE); //set font
	void  SetDefaultFont(); //set default fonts
	void  GetFont(CFont & font);
	void  GetFont(LPLOGFONT lf);

	void RelayEvent(MSG* pMsg);

	//The help tooltip functions
	void ShowHelpTooltip(CPoint & pt, UINT nIdText, HICON hIcon = NULL); //show tooltip as helper
	void ShowHelpTooltip(CPoint & pt, UINT nIdText, UINT nIdIcon); //show tooltip as helper
	void ShowHelpTooltip(CPoint & pt, CString sTooltipText, HICON hIcon = NULL); //show tooltip as helper
	void ShowHelpTooltip(CPoint & pt, CString sTooltipText, UINT nIdIcon); //show tooltip as helper
	void ShowHelpTooltip(CPoint & pt, PPTOOLTIP_INFO & ti); //show tooltip as helper

	static short GetVersionI()		{return 0x14;}
	static LPCTSTR GetVersionC()	{return (LPCTSTR)_T("1.4");}
	// Generated message map functions
protected:
	void KillTimers(UINT nIDTimer = NULL);
	
	CSize PrintTitleString(CDC * pDC, CRect rect, CString str, BOOL bCalculate = TRUE); //Prints the title string
	void  DrawHorzLine(CDC * pDC, int xStart, int xEnd, int y) const;

	void PrepareDisplayToolTip(CPoint * pt); //Notifying parent, Determines the size of tooltip's rect
	void DisplayToolTip(CPoint * pt, CRect * rect);
	
	void SetNewToolTip(int nIndexTool, BOOL bWithDelay = TRUE);
	void Pop();

	BOOL IsEnabledIndexTool(int nIndex);
	BOOL IsCursorInToolTip() const;
	inline BOOL IsVisible() const { return ((GetStyle() & WS_VISIBLE) == WS_VISIBLE); }

	CSize GetTooltipSize(CString str); //Gets max rectangle for display tooltip text
	CSize GetSizeIcon(HICON hIcon) const;
	void CalculateInfoBoxRect(CPoint * pt, CRect * rect);

	CString SearchBeginOfTag(CString & str, int & nIndex);
	void SearchEndOfTag(CString & str, int & nIndex);
	CString GetNameOfTag(CString & str, int & nIndex);
	CString GetPropertiesOfTag(CString & str, int & nIndex);
	CString GetStringValue(CString & str, int & nIndex);
	UINT GetUIntValue(CString & str, int & nIndex, UINT nDefValue);

	LPLOGFONT GetSystemToolTipFont() const;

	int   GetNextHorizDirection(int nDirection) const;
	int   GetNextVertDirection(int nDirection) const;
	BOOL  TestHorizDirection(int x, int cx, int w_cx, int nDirection, LPRECT rect) const;
	BOOL  TestVertDirection(int y, int cy, int w_cy, int nDirection, LPRECT rect) const;

	CRect GetWindowRegion(CRgn * rgn, CSize sz, CPoint pt);
	void  FillGradient(CDC * pDC, CRect rect, COLORREF colorStart, COLORREF colorFinish, BOOL bHorz = TRUE);

	LRESULT SendNotify(CPoint * pt, PPTOOLTIP_INFO & ti);

	void  OnRedrawClient(CDC * pDC);
	void  OnDraw(CDC * pDC, CRect rect);
	void  OnDrawBackground(CDC * pDC, CRect * pRect);
	void  OnDrawShadow(CDC * pDC);
		
	CSize DrawIconFromImageList(CDC * pDC, CPoint pt, CSize sz, CImageList & img, int nIndex = 0, BOOL bCalculate = TRUE);
	CSize DrawResource(CString sName, CDC * pDC, CPoint pt, int nMaxHeight, CSize szResource, BOOL bCalculate);
	CSize DrawBitmap(CDC * pDC, CPoint pt, int nMaxHeight, UINT nID, BOOL bUseMask, COLORREF crMask, CSize szBitmap, BOOL bCalculate);
	CSize DrawIcon(CDC * pDC, CPoint pt, int nMaxHeight, UINT nID, CSize szIcon, BOOL bCalculate);

	HWND GetWndFromPoint(CPoint & pt, BOOL bGetDisabled = TRUE) const;

//	HICON GetIconFromResources(CString sResName, CSize szIcon = CSize(0, 0)) const;
	HICON GetIconFromResources(UINT nID, CSize szIcon = CSize(0, 0)) const;
	HBITMAP GetBitmapFromResources(UINT nID) const;

	//{{AFX_MSG(CPPToolTip)
	afx_msg void OnPaint();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnDestroy();
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif










































⌨️ 快捷键说明

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