void ApplicationListDlg::OnProgramClick(LPNMITEMACTIVATE lpnmitem) { if (IsEditing()) EndEdit(); if (lpnmitem->iItem != -1 && lpnmitem->iSubItem == 1) BeginEdit(lpnmitem->iItem); }
BOOL CSmartFieldListBox::OnFinishEdit(BOOL fValidate /*=TRUE*/, BOOL fByReturn /*=FALSE*/) { int nCurSel = GetCurSel(); int nCount = GetCount(); CSmartFieldsDialog* pParent = (CSmartFieldsDialog*)GetParent(); BOOL fModified = m_pEditor->GetEditor()->GetModify(); if (INHERITED::OnFinishEdit(fValidate, fByReturn)) { if (fModified) { /* // Field is valid. // Update the macro in the project. */ if (nCurSel == GetCurSel() && nCount == GetCount()) { /* Get the macro index so we will know which one to update. */ CSmartFieldListBoxItem* pItem = (CSmartFieldListBoxItem*)GetItemData(nCurSel); if (pItem != NULL) { pParent->UpdateFields(TRUE, pItem->Index()); } } } if (fByReturn) { TRACE(">>> Advance to next field! <<<\n"); int nCurSel = GetCurSel(); int nCount = GetCount(); if (nCurSel != nCount-1) { BeginEdit(nCurSel+1); } else { CWnd* pCloseButton = pParent->GetDlgItem(IDC_CLOSE); if (pCloseButton != NULL) { pCloseButton->SetFocus(); } } } return TRUE; } return FALSE; }
// CHgzListCtrl 消息处理程序 void CHgzListCtrl::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 BOOL bSelected = FALSE; // 得到被点击的Item LVHITTESTINFO testinfo; testinfo.pt = point; //点击时的鼠标位置 //testinfo.flags = LVHT_ONITEM; //点击的必须不是标题 if( SubItemHitTest(&testinfo)<0 ) goto defalt_session; //没有点在有效区域,不进入编辑 // 检查是否有Item正被编辑 if (m_bEditing == TRUE) { if (m_nItem == testinfo.iItem && m_nSubItem == testinfo.iSubItem) goto defalt_session; else EndEdit(TRUE); } int m = m_nItem; int n = m_nSubItem; m_nItem = testinfo.iItem; //被点击表项的行号 m_nSubItem = testinfo.iSubItem; //被点击表项的列号 Update(m); if(m_nSubItem == 0) { bSelected = IsItemSelected(m_nItem) && GetSelectedCount() == 1; goto defalt_session; //点中第一列,不编辑 } // 开始编辑 CListCtrl::OnLButtonDown(nFlags, point); m_bEditing = BeginEdit(); return; defalt_session: CListCtrl::OnLButtonDown(nFlags, point); if (m_nSubItem == 0 && bSelected) { SetItemState(m_nItem, 0, LVIS_SELECTED); SetItemState(m_nItem, 0, LVIS_FOCUSED); } }
void CEditTable::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 POSITION pos; BOOL bSelected = FALSE; if( m_bEditing ==TRUE) goto defalt_session; // 检查是否有Item被选中,没有时不进入编辑 pos = GetFirstSelectedItemPosition(); if( pos ) { // 得到被点击的Item LVHITTESTINFO testinfo; testinfo.pt.x = point.x; testinfo.pt.y = point.y; //点击时的鼠标位置 testinfo.flags = LVHT_ONITEMLABEL; if( SubItemHitTest(&testinfo)<0 ) //点击的必须是标题 goto defalt_session; //没有点在有效区域,不进入编辑 m_nItem = testinfo.iItem; //被点击表项的行号 m_nSubItem = testinfo.iSubItem; //被点击表项的列号 if(m_nSubItem == 0) { goto defalt_session; //选中第一列,不编辑 } // 检查该表项是否被选中,没被选中不进入编辑 while( pos ) if( m_nItem==GetNextSelectedItem(pos) ) { bSelected = TRUE; break; } if( bSelected==FALSE ) goto defalt_session; //没有点在有效区域,不编辑 // 开始编辑 m_bEditing = BeginEdit(); return; } defalt_session: CListCtrl::OnLButtonDblClk(nFlags, point); }
void CSmartFieldListBox::OnAbortEdit(void) { INHERITED::OnAbortEdit(); BeginEdit(); }