- 环境:vs2019,Unicode,C++
- 在 MFC 中有一编辑框 ID 为 IDC_EDIT_PATH,那么步骤如下:
- 在 *Dlg.h 的 class *Dlg 里添加成员变量 CToolTipCtrl m_tooltip;
- 在*Dlg::OnInitDialog()函数里创建线程 m_tooltip.Create(this); 并设置相关参数,具体如下代码:
- *Dlg.h
-
#pragma once #include <afxwin.h> #include <iostream> using namespace std; class *Dlg : public CDialogEx { public: *Dlg(CWnd* pParent = nullptr); // 标准构造函数 ~*Dlg(); public: CToolTipCtrl m_tooltip; //提示 void MsgTips(); //提示功能 }
-
*Dlg.cpp
-
#include "*Dlg.h" BOOL *Dlg::OnInitDialog() { //...省略一些自带的代码...// // TODO: 在此添加额外的初始化代码 m_tooltip.Create(this); MsgTips(); } void *Dlg::MsgTips() { USES_CONVERSION; int errcode; m_tooltip.AddTool(GetDlgItem(IDC_EDIT_PATH), _T("D:\*.png")); // 设置提示信息 m_tooltip.SetTipTextC