/***************************************************************************** Processes mouse clicks that potentially hit an embedded cell control *****************************************************************************/ BOOL CGridBtnCellBase::ProcessCtlClick(UINT uMsg, // Command that invoked. e.g. WM_LBUTTONDOWN const CPoint& arPoint) // point to check for hit // returns: T=hit a control / F=no control hit { int iCtlHit = RelPointInCtl( arPoint); // Relative point coords // returns: Index of control that this point is within bounds of or -1 if no control matches if( iCtlHit >= 0) { ClickedCellCtl( uMsg, // Command that invoked. e.g. WM_LBUTTONDOWN iCtlHit); // zero-based index of image to draw return TRUE; } m_sLastCtlClicked = -1; return FALSE; }
/***************************************************************************** May mean end of a button click sequence or to edit text *****************************************************************************/ BOOL CGridBtnCellCombo::Edit(int nRow, int nCol, CRect rect, CPoint point, UINT nID, UINT nChar) { int iCtlHit = RelPointInCtl( point); // Relative point coords // returns: Index of control that this point is within bounds of or -1 if no control matches BOOL bShowDropDownNow = FALSE; if( iCtlHit >= 0) { // if user clicked on scroll down button picture, then show // the drop-down, too UINT uiType = GetDrawCtlType( iCtlHit); UINT uiState = GetDrawCtlState( iCtlHit); bShowDropDownNow = ( uiType == DFC_SCROLL) && uiState & DFCS_SCROLLDOWN; } BOOL bHitNonComboButton = ( iCtlHit >= 0) && !bShowDropDownNow; if( HasCellText() && !bHitNonComboButton ) { m_ucEditing = TRUE; // InPlaceList auto-deletes itself CGridCtrl* pGrid = GetGrid(); CInPlaceList* pInPlaceList = new CInPlaceList( pGrid, rect, m_dwComboStyle, nID, nRow, nCol, GetTextClr(), GetBackClr(), m_StringArrayCombo, GetText(), nChar); if( bShowDropDownNow) { if( m_dwComboStyle & CBS_DROPDOWN || m_dwComboStyle & CBS_DROPDOWNLIST) { pInPlaceList->ShowDropDown( TRUE); } } m_pBtnDataBase->SetEditWnd( pInPlaceList); return TRUE; } // call base class, otherwise return CGridBtnCell::Edit( nRow, nCol, rect, point, nID, nChar); }
void CGridBtnCellCombo::OnClick( CPoint PointCellRelative) { // immediately edit if user clicked on scroll down button picture int iCtlHit = RelPointInCtl( PointCellRelative); // Relative point coords // returns: Index of control that this point is within bounds of or -1 if no control matches BOOL bHitScrollDown = FALSE; if( iCtlHit >= 0) { // if user clicked on scroll down button picture, then show // the drop-down, too UINT uiType = GetDrawCtlType( iCtlHit); UINT uiState = GetDrawCtlState( iCtlHit); bHitScrollDown = ( uiType == DFC_SCROLL) && uiState & DFCS_SCROLLDOWN; } if( bHitScrollDown) { // invoke the edit, now -- similar to CGridCtl::OnEditCell() logic CGridCtrl* pGrid = GetGrid(); ASSERT( pGrid != NULL); CRect rect; if (!pGrid->GetCellRect( m_iRow, m_iCol, rect)) return; SendMessageToParent(m_iRow, m_iCol, GVN_BEGINLABELEDIT); Edit( m_iRow, m_iCol, rect, PointCellRelative, IDC_INPLACE_CONTROL, VK_LBUTTON); return; } CGridBtnCell::OnClick( PointCellRelative); }