VC ToolTip提示工具的实现
2010-05-28 17:37
246 查看
1、tooltip是很不错的提示信息,很多程序都需要用到这个信息提示。
2、用VC建立一个Dialog得工程,在Dialog上面拖放一个Button按钮,ID为IDC_BUTTON1。
在CToolTipDlg::OnInitDialog()函数写入如下代码:
IDC_STA,是静态的文本控件,则需要设置 静态文本Notify属性为TRUE
2、用VC建立一个Dialog得工程,在Dialog上面拖放一个Button按钮,ID为IDC_BUTTON1。
CToolTipCtrl m_tooltip; virtual BOOL PreTranslateMessage(MSG* pMsg);
BOOL CToolTipDlg::PreTranslateMessage(MSG* pMsg) { m_tooltip.RelayEvent(pMsg); return CDialog::PreTranslateMessage(pMsg); }
在CToolTipDlg::OnInitDialog()函数写入如下代码:
m_tooltip.Create(this); m_tooltip.Activate(TRUE); m_tooltip.AddTool(GetDlgItem(IDC_BUTTON1), ">text<"); m_tooltip.AddTool(GetDlgItem(IDC_STA), ">text123< /r/n adfdfsdfs"); m_tooltip.SetDelayTime(200);//设置延迟时间 m_tooltip.SetTipBkColor(COLORREF(RGB(100,0,0)));//设置提示背景色 m_tooltip.SetTipTextColor(RGB(0,0,255));//设置提示文本颜色 m_tooltip.SetMaxTipWidth(100);//设置提示的最大宽度(使用多行需要设置此项)
IDC_STA,是静态的文本控件,则需要设置 静态文本Notify属性为TRUE
class CToolTipCtrl : public CWnd { DECLARE_DYNAMIC(CToolTipCtrl) // Constructors public: CToolTipCtrl(); BOOL Create(CWnd* pParentWnd, DWORD dwStyle = 0); // Attributes void GetText(CString& str, CWnd* pWnd, UINT nIDTool = 0) const; BOOL GetToolInfo(CToolInfo& ToolInfo, CWnd* pWnd, UINT nIDTool = 0) const; void SetToolInfo(LPTOOLINFO lpToolInfo); void SetToolRect(CWnd* pWnd, UINT nIDTool, LPCRECT lpRect); int GetToolCount() const; int GetDelayTime(DWORD dwDuration) const; void SetDelayTime(DWORD dwDuration, int iTime); void GetMargin(LPRECT lprc) const; void SetMargin(LPRECT lprc); int GetMaxTipWidth() const; int SetMaxTipWidth(int iWidth); COLORREF GetTipBkColor() const; void SetTipBkColor(COLORREF clr); COLORREF GetTipTextColor() const; void SetTipTextColor(COLORREF clr); // Operations void Activate(BOOL bActivate); BOOL AddTool(CWnd* pWnd, UINT nIDText, LPCRECT lpRectTool = NULL, UINT nIDTool = 0); BOOL AddTool(CWnd* pWnd, LPCTSTR lpszText = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT nIDTool = 0); void DelTool(CWnd* pWnd, UINT nIDTool = 0); BOOL HitTest(CWnd* pWnd, CPoint pt, LPTOOLINFO lpToolInfo) const; void RelayEvent(LPMSG lpMsg); void SetDelayTime(UINT nDelay); void UpdateTipText(LPCTSTR lpszText, CWnd* pWnd, UINT nIDTool = 0); void UpdateTipText(UINT nIDText, CWnd* pWnd, UINT nIDTool = 0); void Update(); void Pop(); // Implementation public: void FillInToolInfo(TOOLINFO& ti, CWnd* pWnd, UINT nIDTool) const; virtual ~CToolTipCtrl(); #ifndef _AFXDLL virtual BOOL DestroyToolTipCtrl(); #else BOOL DestroyToolTipCtrl(); #endif protected: //{{AFX_MSG(CToolTipCtrl) afx_msg LRESULT OnDisableModal(WPARAM, LPARAM); afx_msg LRESULT OnWindowFromPoint(WPARAM, LPARAM); afx_msg LRESULT OnAddTool(WPARAM, LPARAM); afx_msg void OnEnable(BOOL bEnable); //}}AFX_MSG DECLARE_MESSAGE_MAP() CMapStringToPtr m_mapString; friend class CWnd; friend class CToolBar; };
相关文章推荐
- VC中用CPPToolTip轻松实现工具提示
- VC中用CPPToolTip轻松实现工具提示
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VB中ToolTip工具提示的完美实现
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VC为控件加ToolTip工具提示方法总结
- VC.NET界面编程中关于的ToolBar(工具栏)的编程应用(二)2008/07/01 19:22 上回说到给工具栏上添加IE风格的下拉菜单按钮,我们通过设置工具栏按钮的风格已经完成了下拉菜单按钮的添加,现在我们准备为下拉菜单按钮中响应下拉箭头部分的实现
- 实验室网站所遇技术(二) AJAX实现工具提示
- VC中给树形控件的图标加上工具提示
- [工具]类QQ消息通知,提示博客园发布新文章(二)——托盘实现
- 纯CSS实现tooltip提示框,CSS箭头及形状
- 纯CSS实现tooltip提示框,CSS箭头及形状
- 网页素材:精美的免费工具提示(ToolTip)PSD 素材