C++ 中CListCtrl的每個項都顯示不同的提示信息
添加CToolTipCtrl成員變量m_toolTipCtrl,CListCtrl成員變量m_ListUser,CImageList成員變量m_imageList(這個可以不要)
在OnInitDialog()函數里加下面代碼
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;     bit.LoadBitmap(IDB_TEA_ONLINE+i);     m_imageList.Add(&bit, RGB(0, 0, 0));     bit.DeleteObject();   }      EnableToolTips(TRUE);   m_toolTipCtrl.Create(this);   m_toolTipCtrl.SetMaxTipWidth(500);//若屏蔽這行提示信息的格式可能會出現問題,不能換行   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); 添加虛函數PreTranslateMessage()
在函數里添加下面代碼
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); } 如有疑問請留言或者到本站社區交流討論,希望通過本文能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答
圖片精選