正在装载数据…… //判断双击的ITEM是否有父ITEM,如果有,弹出聊天窗口;否则,则展开或收缩ITEM void CIMTree::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here //MessageBox("d"); //判断是否是你项目,如果是父项目,则不弹出聊天对话框,否则,弹出聊天对话框 HTREEITEM hitem; hitem=this->GetSelectedItem(); if(this->GetParentItem(hitem)) { //将点击项目的用户名传递给聊天对话框 CString test=this->GetItemText(hitem); CIMChat dlgChat; dlgChat.SetUserInfo(test); dlgChat.DoModal(); } *pResult = 0; } //如果鼠标在某个ITEM上,弹出一个菜单;如果鼠标在空白区,弹出另一个菜单 void CIMTree::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) { HTREEITEM hSelect = this->GetSelectedItem(); HTREEITEM hLight = this->GetDropHilightItem(); if(hLight != NULL && hSelect != hLight) hSelect = hLight; if(hSelect == NULL) return; this->SelectItem(hSelect); CPoint point; ::GetCursorPos(&point); POINT tempPoint; tempPoint.x=point.x; tempPoint.y=point.y; m_hSelectItem=this->GetSelectedItem(); RECT itemRect; RECT windowRect; ::GetWindowRect(this->m_hWnd,&windowRect); this->GetItemRect(m_hSelectItem,&itemRect,TRUE); // UINT nFlags; // this->HitTest(point,&nFlags); if((m_hSelectItem != NULL)&& (tempPoint.x>itemRect.left+windowRect.left&& tempPoint.x<itemRect.right+windowRect.left&& tempPoint.y>itemRect.top+windowRect.top&& tempPoint.y<itemRect.bottom+windowRect.top) /* && (TVHT_ONITEM & nFlags)*/) { CMenu menu; CMenu *ptrMenu; menu.LoadMenu(IDR_MENU1); ptrMenu=menu.GetSubMenu(0); ptrMenu->TrackPopupMenu ( TPM_LEFTALIGN|TPM_RIGHTBUTTON, tempPoint.x, tempPoint.y, this, NULL ); } else { CMenu menu; CMenu *ptrMenu; menu.LoadMenu(IDR_MENU2); ptrMenu=menu.GetSubMenu(0); ptrMenu->TrackPopupMenu ( TPM_LEFTALIGN|TPM_RIGHTBUTTON, tempPoint.x, tempPoint.y, this, NULL ); } *pResult = 0; }
本文来源:http://blog.csdn.net/cyrx2003/archive/2007/08/23/1756781.aspx
|