Each item of CListCtrl in C++ displays a different prompt message
Add CToolTipCtrl member variable m_toolTipCtrl, CListCtrl member variable m_ListUser, CImageList member variable m_imageList (this can be done without)
Add the following code to the OnInitDialog() function
m_BoradcastEnd.EnableWindow(FALSE); m_imageList.Create(32, 32, ILC_COLOR8, 2, 2); DWORD dwStyle = m_ListUser.GetExtendedStyle(); dwStyle |= LVS_EX_INFOTIP; m_ListUser.SetExtendedStyle(dwStyle); for (int i=0; i<5; i++) { CBitmap bit; (IDB_TEA_ONLINE+i); m_imageList.Add(&bit, RGB(0, 0, 0)); (); } EnableToolTips(TRUE); m_toolTipCtrl.Create(this); m_toolTipCtrl.SetMaxTipWidth(500);//If you block the format of this line prompt message, you may have problems and you cannot change the line m_toolTipCtrl.Activate(TRUE); m_ListUser.SetImageList(&m_imageList, TVSIL_NORMAL); m_ListUser.InsertItem(0, "172.16.30.32.231", 0); m_ListUser.InsertItem(1, "172.16.30.218", 4); CRect rect; m_ListUser.GetItemRect(0, &rect, LVIR_BOUNDS); m_toolTipCtrl.AddTool(&m_ListUser, "MAC:/nHost:/nIP:", &rect, 1); m_ListUser.GetItemRect(1, &rect, LVIR_BOUNDS); m_toolTipCtrl.AddTool(&m_ListUser, "gggggggggg/nggggggggsfgsfgsfg", &rect, 2);
Add virtual function PreTranslateMessage()
Add the following code to the function
BOOL CMutiScreenDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class m_toolTipCtrl.RelayEvent(pMsg); return CDialog::PreTranslateMessage(pMsg); }
If you have any questions, please leave a message or go to the community of this website to exchange and discuss. I hope this article can help you. Thank you for your support for this website!