void CGridCtrlEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CCellID cell = GetFocusCell(); if (!IsValid(cell)) { CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags); return; } if (IsCTRLpressed()) { switch (nChar) { case 'F': OnFind(); return; } } else { switch (nChar) { case VK_F3: OnFindContinue(); return; } } CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags); }
/** @brief FindName을 찾는다. @author KHS @date 2009-05-26 오후 3:18:13 @param @return **/ bool CGridCtrlEx::FindWhatYouNeed(CString FindName, bool bMatchCase, bool bMatchWholeWord, bool bSearchDown) { if(bMatchCase == false) FindName.MakeUpper(); bool bContinueSearch = true; CCellID startCell = GetFocusCell(); CCellID actCell = startCell; if(IsValid(actCell)) { goto L_SEARCH; } do { actCell.col = 1; actCell.row = 1; for(actCell = bSearchDown ? actCell : GetPrevCell(actCell); bContinueSearch && IsValid(actCell);) { if(actCell == startCell) { bContinueSearch = false; break; } { CString rName = CGridCtrlEx::GetItemText(actCell.row, actCell.col); if(bMatchCase == false) rName.MakeUpper(); if((bMatchWholeWord && rName == FindName) || (!bMatchWholeWord && (rName.Find(FindName) >= 0))) { SetSelectedRange(actCell.row, actCell.col,actCell.row, actCell.col); SetFocusCell(actCell); //!SCROL BAR MOVE ScrollMove(startCell, actCell); return true; } } L_SEARCH: actCell = bSearchDown ? GetNextCell(actCell) : GetPrevCell(actCell); } if(!IsValid(actCell)) { bContinueSearch = false; } }while(bContinueSearch); return false; // not found }
/** @brief Find Replace Dialog @author KHS @date 2009-05-26 오후 1:34:14 @param @return **/ int CGridCtrlEx::OnFind(void) { CCellID cell = GetFocusCell(); if(cell.IsValid()) { m_pFindDialog = new CFindReplaceDialog(); if(m_pFindDialog) { m_pFindDialog->Create(TRUE, "", NULL, FR_DOWN, this); } return ERROR_SUCCESS; } return ERROR_BAD_ENVIRONMENT;; }
int CTradeGridBase::GetCurrCol() { return GetFocusCell().col; }
int CTradeGridBase::GetCurrRow() { return GetFocusCell().row; }