下载本文示例代码
ClassWizard为CTreeCtrl(树控件)添加的NM_DBLCLK(双击)消息的响应函数中带有一个NMHDR * 型指针形参:
OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult) 这个陌生的指针类型常使初用树控件的编程者陷入迷茫之中。实际上我们完全不理会它,也可以实现树控件的双击响应,即在OnDblClkTree( )函数中调用树控件的成员函数CTreeCtrl::GetSelectedItem( )以获取树控件的子项句柄HTREEITEM,得到此句柄后,我们便可用下列成员函数获取子项各种有用信息: CTreeCtrl::GetItemData( )、 CTreeCtrl::GetItemHeight( )、 CTreeCtrl::GetItemImage( )、 CTreeCtrl::GetItemRect( )、 CTreeCtrl::GetItemState( )、 CTreeCtrl::GetItemText( )。 例程运行结果如下图所示:
示例代码如下:
class CTreeCtrlDlg : public CDialog{…………public:HTREEITEM m_hTreeItem;CImageList m_ImgLst;// Dialog Data//{{AFX_DATA(CTreeCtrlDlg)enum { IDD = IDD_TREECTRL_DIALOG };CTreeCtrl m_wndTree;//与对话框中树控件相关联//}}AFX_DATA// Implementationprotected:afx_msg void OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult);…………};void CTreeCtrlDlg::OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult) {m_hTreeItem = m_wndTree.GetSelectedItem();//以GetItemText()函数为例:CString S1 = m_wndTree.GetItemText(m_hTreeItem);AfxMessageBox("You have selected " S1);*pResult = 0; }zmbbs=1;
ClassWizard为CTreeCtrl(树控件)添加的NM_DBLCLK(双击)消息的响应函数中带有一个NMHDR * 型指针形参:
OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult) 这个陌生的指针类型常使初用树控件的编程者陷入迷茫之中。实际上我们完全不理会它,也可以实现树控件的双击响应,即在OnDblClkTree( )函数中调用树控件的成员函数CTreeCtrl::GetSelectedItem( )以获取树控件的子项句柄HTREEITEM,得到此句柄后,我们便可用下列成员函数获取子项各种有用信息: CTreeCtrl::GetItemData( )、 CTreeCtrl::GetItemHeight( )、 CTreeCtrl::GetItemImage( )、 CTreeCtrl::GetItemRect( )、 CTreeCtrl::GetItemState( )、 CTreeCtrl::GetItemText( )。 例程运行结果如下图所示:
示例代码如下:
class CTreeCtrlDlg : public CDialog{…………public:HTREEITEM m_hTreeItem;CImageList m_ImgLst;// Dialog Data//{{AFX_DATA(CTreeCtrlDlg)enum { IDD = IDD_TREECTRL_DIALOG };CTreeCtrl m_wndTree;//与对话框中树控件相关联//}}AFX_DATA// Implementationprotected:afx_msg void OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult);…………};void CTreeCtrlDlg::OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult) {m_hTreeItem = m_wndTree.GetSelectedItem();//以GetItemText()函数为例:CString S1 = m_wndTree.GetItemText(m_hTreeItem);AfxMessageBox("You have selected " S1);*pResult = 0; }zmbbs=1;
下载本文示例代码
VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应VC轻松实现CTreeCtrl控件双击响应
阅读(149) | 评论(0) | 转发(0) |