C++のCListCtrlの各項目には、異なる提示情報が表示されます。

1769 ワード

C++のCListCtrlの各項目には、異なる提示情報が表示されます。
CToolTipCtrlメンバー変数m_を追加します。tool TipCtrl、CListCtrlメンバー変数m_ListUser、CImageListメンバー変数m_イマジリスト(これはいらなくてもいいです。)
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); 
ダミー関数Protanslate Message()を追加します。
関数に下記のコードを追加します。

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); 
} 
疑問があれば、メッセージをお願いします。あるいは、当駅のコミュニティ交流討論に来てください。本文を通じて皆さんに助けてほしいです。ありがとうございます。