网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 网络学院 >> 程序设计 >> VC编程 >> 文章正文
  关于CTreeCtrlr的=NM_DBLCLK、=NM_RCLICK的用法            【字体:
关于CTreeCtrlr的=NM_DBLCLK、=NM_RCLICK的用法
作者:佚名    文章来源:不详    点击数:    更新时间:2007-9-12    
正在装载数据……

//判断双击的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
站内文章搜索 高级搜索
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
     directx 图形接口指南(…
     win2k下的api函数的拦截
     用crypto  api  实现公钥…
     根据别人的md5源码封装的…
     vc中使用gdi+合并jpg图片
     document/view的交互 --…
     windows下的函数hook技术
     windows api函数大全一
     用vc 6.0实现串行通信的…
     vc++技术内幕(第四版)…
  • page、request、session、ap…

  • JSF 的性能远不及 JSP 或 St…

  • J2EE运行环境的搭建

  • HashTable和HashMap; Vecto…

  • 关于java Applet

  • Core Java 之旅

  • Struts2学习:在struts2中集…

  • [ZT]关于用jar打包(分享)

  • java中关于时间日期操作的常…

  • 浅析Spring框架下PropertyPl…

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    网络学院©2007 www.23book.net
    为您提供web编程,vb编程,vc编程,服务器架设管理,数据库设计等方面的知识 站长:David