赞
踩
输入完成,点击空白处:
在这里,响应List Control的双击事件:
- 1 void CAddInstanceDlg::OnNMDblclkList3(NMHDR * pNMHDR, LRESULT * pResult)
- 2 {
- 3 LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast < LPNMITEMACTIVATE > (pNMHDR);
- 4
- 5 LVHITTESTINFO info;
- 6 info.pt = pNMItemActivate -> ptAction;
- 7
- 8 if (listControl.SubItemHitTest( & info) != - 1 )
- 9 {
- 10 hitRow = info.iItem;
- 11 hitCol = info.iSubItem;
-
- 12 if (editItem.m_hWnd == NULL) // editItem为一输入框控件,
- 13 {
- 14 RECT rect;
- 15 rect.left = 0 ;
- 16 rect.top = 0 ;
- 17 rect.bottom = 15 ;
- 18 rect.right = 200 ;
- 19 editItem .Create(WS_CHILD | ES_LEFT | WS_BORDER | ES_AUTOHSCROLL | ES_WANTRETURN | ES_MULTILINE, rect, this , 101 );
- 20 editItem.SetFont( this -> GetFont(), FALSE);
- 21 }
- 22 CRect rect;
- 23 listControl.GetSubItemRect(info.iItem, info.iSubItem, LVIR_BOUNDS, rect);
- 24 rect.top += 12 ;
- 25 rect.left += 13 ;
- 26 rect.right += 13 ;
- 27 rect.bottom += 12 ;
- 28
- 29 editItem.SetWindowText(listControl.GetItemText( info .iItem, info .iSubItem));
- 30 editItem.MoveWindow( & rect, TRUE);
- 31 editItem.ShowWindow( 1 );
- 32 editItem.SetFocus();
- 33 }
- 34 * pResult = 0 ;
- 35 }

- void CAddInstanceDlg::OnNMClickList3(NMHDR * pNMHDR, LRESULT * pResult)
- 2 {
- 3 LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast < LPNMITEMACTIVATE > (pNMHDR);
- 4
- 5 if (editItem.m_hWnd != NULL)
- 6 {
- 7 editItem.ShowWindow( 0 );
- 8 if (hitRow != - 1 )
- 9 {
- 10 CString text;
- 11 editItem.GetWindowText(text);
- 12 listControl.SetItemText(hitRow, hitCol, text);
- 13 }
- 14 }
- 15 hitCol = hitRow = - 1 ;
- 16 * pResult = 0 ;
- 17 }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。