NMHDR

 NMHDR   =   Notify   Message   Handler

 

NMHDR   结构包含下列成员: 
  typedef   struct   tagNMHDR   { 
  HWND   hwndFrom;     //   handle   of   control   sending   message 
  UINT   idFrom;//   identifier   of   control   sending   message 
  UINT   code;     //   notification   code;   see   below 
  }   NMHDR; 
  
  消息通过下面的宏定义之: 
  ON_NOTIFY(   wNotifyCode,   idControl,   memberFxn   ) 
  wNotifyCode   
  通知消息标识符代码,如   TBN_BEGINADJUST。   
  idControl   
  发送通知的控件的标识符。   
  memberFxn   
  接收到通知时调用的成员函数。   
  
  成员函数将用下列原型声明: 
  afx_msg   void   memberFxn(   NMHDR   *   pNotifyStruct,   LRESULT   *   result   ); 

 

在WM_NOTIFY中,lParam中放的是一个称为NMHDR结构的指针。在wParam中放的则是控件的ID。 

 

 

 

举例://得到选中的列

void   CMyView::OnColumnclick(NMHDR*   pNMHDR,   LRESULT*   pResult)   
  {       
  NM_LISTVIEW*   pNMListView   =   (NM_LISTVIEW*)pNMHDR; 
    

//得到选中的列      
  column=pNMListView->iSubItem;  

}

 

 

void CBillDlg2::OnGridEndEdit(NMHDR *pNotifyStruct ,LRESULT *pResult)//响应控件通知消息GVN_ENDLABELEDIT
{//自定义这个消息响应函数
  if(m_showbill)//控制显示对话框
  return ;
  /*typedef   struct   tagNMHDR  
  {  
          HWND     hwndFrom;  
          UINT     idFrom;  
          UINT     code;                   //   NM_   code  
  }      NMHDR; */  

  NM_GRIDVIEW *pitem=(NM_GRIDVIEW *)pNotifyStruct;
  if(pitem->iRow<0)
   return ;
 
  if(pitem->iColumn==m_nAmountCol||pitem->iColumn==m_nPriceCol)
  {
    CString  strAmount;
 CString  strPrice;
 strAmount=m_Grid.GetItemText(pitem->iRow,m_nAmountCol);
 strPrice=m_Grid.GetItemText(pitem->iRow,m_nPriceCol);
 int nAmount=atoi(strAmount);
 if(nAmount<=0)
  return;
 float fPrice=atof(strPrice);
 if(fPrice<=0)
 

 return;

 double dmoney=fPrice*(double)nAmount;
 CString  strMoney;
    strMoney.Format("%f",dmoney);
 m_Grid.SetItemText(pitem->iRow,m_nMoneyCol,strMoney);


  }

m_Grid.Refresh();

}

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/markman101/archive/2008/12/23/3591355.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值