Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtGridInplaceEdit and VK_DELETE Collapse All
Subject Author Date
Richard Rodruck Oct 17, 2007 - 9:50 AM

I am trying to capture the VK_DELETE message but the CExtGridInplaceEdit message loop doesn’t let it pass through. Is there a way to do so?

Richard Rodruck Oct 19, 2007 - 9:34 AM

Thanks, that works

Technical Support Oct 18, 2007 - 1:16 PM

Yes we agree with you that this is our fault. You can fix this problem by updating the following method and recompiling the library. Note this fix will be available in Prof-UIS 2.81

bool CExtGridWnd::OnGbwBeginEdit(
	LONG nVisibleColNo,
	LONG nVisibleRowNo,
	LONG nColNo,
	LONG nRowNo,
	INT nColType,
	INT nRowType,
	const RECT & rcCellExtra,
	const RECT & rcCell,
	const RECT & rcInplaceControl,
	bool bContinueMsgLoop, // = true
	__EXT_MFC_SAFE_LPCTSTR strStartEditText // = NULL
	)
{
	ASSERT_VALID( this );
	if(	CExtGridBaseWnd::OnGbwBeginEdit(
			nVisibleColNo,
			nVisibleRowNo,
			nColNo,
			nRowNo,
			nColType,
			nRowType,
			rcCellExtra,
			rcCell,
			rcInplaceControl,
			bContinueMsgLoop,
			strStartEditText
			)
		)
		return true;

	if(	CExtPopupMenuWnd::IsMenuTracking() )
		CExtPopupMenuWnd::CancelMenuTracking();
	CWnd::CancelToolTips();

//DWORD dwBseStyle = BseGetStyle();
//	if( nColType < 0 && (dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_L) == 0L )
//		return false;
//	else if( nColType > 0 && (dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_R) == 0L )
//		return false;
//	else if( nColType == 0 && (dwBseStyle&__EGWS_BSE_EDIT_CELLS_INNER) == 0L )
//		return false;
//	else if( nRowType < 0 && (dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_T) == 0L )
//		return false;
//	else if( nRowType > 0 && (dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_B) == 0L )
//		return false;
//	else if( nRowType == 0 && (dwBseStyle&__EGWS_BSE_EDIT_CELLS_INNER) == 0L )
//		return false;

DWORD dwBseStyle = BseGetStyle();
	if(			nColType < 0
		&&		(dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_L) == 0L
		)
		return false;
	else if(	nColType > 0
		&&		(dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_R) == 0L
		)
		return false;
	else if(	nRowType < 0
		&&		(dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_T) == 0L
		)
		return false;
	else if(	nRowType > 0
		&&		(dwBseStyle&__EGWS_BSE_EDIT_CELLS_OUTER_B) == 0L
		)
		return false;
	else if(	nColType == 0
		&&		nRowType == 0
		&&		(dwBseStyle&__EGWS_BSE_EDIT_CELLS_INNER) == 0L
		)
		return false;

static CExtGridCell * g_pEditCell = NULL;
bool bDoMsgLoop = true;
	if( m_hWndInplaceControl != NULL )
	{
		if( ! bContinueMsgLoop )
			return false;
		HWND hWndInplaceControl = m_hWndInplaceControl;
		m_hWndInplaceControl = NULL;
		if( hWndInplaceControl != NULL )
		{
			bDoMsgLoop = false;
			if( ::IsWindow(hWndInplaceControl) )
				::DestroyWindow( hWndInplaceControl );
		} // if( hWndInplaceControl != NULL )
	} // if( m_hWndInplaceControl != NULL )
CRect rcActivate( rcInplaceControl );
	if(		rcActivate.left >= rcActivate.right
		||	rcActivate.top >= rcActivate.bottom
		)
	{ // if invalid rect - recalc it
		if(	! GridCellRectsGet(
				nColNo,
				nRowNo,
				nColType,
				nRowType,
				NULL,
				NULL,
				NULL,
				&rcActivate // pRectTextArea
				)
			)
		{
			g_pEditCell = NULL;
			return false;
		}
		if( rcActivate.IsRectEmpty() )
		{
			g_pEditCell = NULL;
			return false;
		}
	} // if invalid rect - recalc it
//CClientDC dc( this );
//	dc.FillSolidRect( &rcActivate, RGB(255,0,0) );
//CString strMsg;
//strMsg.Format( _T("CExtGridWnd::OnGbwBeginEdit(%ld,%ld,%ld,%ld,%d,%d)"),nVisibleColNo,nVisibleRowNo,nColNo,nRowNo,nColType,nRowType);
//::AfxMessageBox( strMsg, MB_ICONINFORMATION );
CExtGridCell * pCellToEdit =
		GridCellGet(
			nColNo,
			nRowNo,
			nColType,
			nRowType
			);
	if( pCellToEdit == NULL )
		return false;
	ASSERT_VALID( pCellToEdit );
	ASSERT( pCellToEdit->IsKindOf(RUNTIME_CLASS(CExtGridCell)) );
	ASSERT_VALID( pCellToEdit->DataProviderGet() );
	g_pEditCell = pCellToEdit;
	m_hWndInplaceControl =
		g_pEditCell->OnInplaceControlCreate(
			*this,
			nVisibleColNo,
			nVisibleRowNo,
			nColNo,
			nRowNo,
			nColType,
			nRowType,
			rcCellExtra,
			rcCell,
			rcActivate,
			m_nHelperLastEditedColNo,
			m_nHelperLastEditedRowNo
			);
	if(		m_hWndInplaceControl == NULL
		||	( ! ::IsWindow( m_hWndInplaceControl ) )
		)
	{
		m_hWndInplaceControl = NULL;
		g_pEditCell = NULL;
		DWORD dwCellStyle = pCellToEdit->GetStyle();
		if( (dwCellStyle&__EGCS_CHK_MASK) == 0 )
		{
			if( (dwCellStyle&__EGCS_BUTTON_DROPDOWN) != 0 )
			{
				bool bEnabled = false;
				if( pCellToEdit->OnQueryButtonInfo(
						INT(CExtGridCell::__EBTT_DROPDOWN),
						&bEnabled
						)
					)
				{
					if( bEnabled )
					{
						pCellToEdit->OnButtonPressed(
							*this,
							INT(CExtGridCell::__EBTT_DROPDOWN),
							rcCellExtra,
							rcCell,
							nVisibleColNo,
							nVisibleRowNo,
							nColNo,
							nRowNo,
							nColType,
							nRowType
							);
						return true;
					} // if( bEnabled )
				}
			} // if( (dwCellStyle&__EGCS_BUTTON_DROPDOWN) != 0 )
// -2.63
// 			if( (dwCellStyle&__EGCS_BUTTON_ELLIPSIS) != 0 )
// 			{
// 				bool bEnabled = false;
// 				if( pCellToEdit->OnQueryButtonInfo(
// 						INT(CExtGridCell::__EBTT_ELLIPSIS),
// 						&bEnabled
// 						)
// 					)
// 				{
// 					if( bEnabled )
// 					{
// 						pCellToEdit->OnButtonPressed(
// 							*this,
// 							INT(CExtGridCell::__EBTT_ELLIPSIS),
// 							rcCellExtra,
// 							rcCell,
// 							nVisibleColNo,
// 							nVisibleRowNo,
// 							nColNo,
// 							nRowNo,
// 							nColType,
// 							nRowType
// 							);
// 						return true;
// 					} // if( bEnabled )
// 				}
// 			} // if( (dwCellStyle&__EGCS_BUTTON_ELLIPSIS) != 0 )
		} // if( (dwCellStyle&__EGCS_CHK_MASK) == 0 )
		return false;
	}
	m_nHelperLastEditedColNo = nColNo;
	m_nHelperLastEditedRowNo = nRowNo;
	if( ! bDoMsgLoop )
		return true;

CWinThread * pThread = ::AfxGetThread();
	ASSERT_VALID( pThread );

	if( strStartEditText != NULL )
	{
		bool bSetText = true;
		TCHAR strClassName[512];
		::GetClassName( m_hWndInplaceControl, strClassName, 512 );
		if( _tcslen( strClassName ) > 0 )
		{
			__EXT_MFC_STRLWR( strClassName, 512 );
			if(		_tcsstr( strClassName, _T("edit") ) != NULL
				||	_tcsstr( strClassName, _T("riched") ) != NULL
				||	_tcsstr( strClassName, _T("sysipaddress32") ) != NULL
				)
			{
				bSetText = false;
				HWND hWndInplaceControl = m_hWndInplaceControl;
				if( _tcsstr( strClassName, _T("sysipaddress32") ) != NULL )
				{
					for(	HWND hWnd = ::GetWindow( m_hWndInplaceControl, GW_CHILD ); 
							hWnd != NULL; 
							hWnd = ::GetWindow( hWnd, GW_HWNDNEXT )
						)
					{
						ASSERT( hWnd != NULL );
						ASSERT( ::IsWindow(hWnd) );
						if( ::GetFocus() == hWnd )
						{
							hWndInplaceControl = hWnd;
							break;
						}
					}
				}
 				::SendMessage( hWndInplaceControl, EM_SETSEL, WPARAM(0), LPARAM(-1) );
 				::SendMessage( hWndInplaceControl, EM_REPLACESEL, WPARAM(TRUE), LPARAM(strStartEditText) );
			}
		} // if( _tcslen( strClassName ) > 0 )
		if( bSetText )
			::SetWindowText( m_hWndInplaceControl, strStartEditText );
	} // if( strStartEditText != NULL )

HWND hWndGrid = m_hWnd;
bool bStopFlag = false;
	for(	MSG msg;
				m_hWndInplaceControl != NULL
			&&	::IsWindow( m_hWndInplaceControl )
			&&	::IsWindowVisible( m_hWndInplaceControl )
			&&	::IsWindow( hWndGrid )
			&&	(!bStopFlag)
			&&	(g_pEditCell != NULL)
			;
		)
	{ // in-place editor message loop
		if( ! ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
		{
			if(		m_hWndInplaceControl == NULL
				||	( ! ::IsWindow( m_hWndInplaceControl ) )
				||	( ! ::IsWindow( hWndGrid ) )
				||	bStopFlag
				||	g_pEditCell == NULL
				)
				break;
			LONG nIdleCounter = 0L;
			for(	nIdleCounter = 0L;
					g_pEditCell->OnInplaceControlIdle(
						m_hWndInplaceControl,
						*this,
						nIdleCounter
						);
					nIdleCounter ++
					)
			{
				ASSERT_VALID( g_pEditCell );
			}
			if( CExtGridWnd::g_bEnableOnIdleCalls )
			{
				for(	nIdleCounter = 0L;
						pThread->OnIdle(nIdleCounter);
						nIdleCounter ++
						);
			}
			::WaitMessage();
			continue;
		} // if( ! ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )

		switch( msg.message )
		{
		case WM_KILLFOCUS:
			if( msg.hwnd == m_hWndInplaceControl )
				bStopFlag = true;
		break;
		case WM_CANCELMODE:
		case WM_ACTIVATEAPP:
		case WM_SYSCOMMAND:
		case WM_SETTINGCHANGE:
		case WM_SYSCOLORCHANGE:
			bStopFlag = true;
		break;
		case WM_COMMAND:
			if(		(HIWORD(msg.wParam)) == 0
				||	(HIWORD(msg.wParam)) == 1
				)
				bStopFlag = true;
		break;
		case WM_CAPTURECHANGED:
			if( (HWND)msg.wParam != m_hWndInplaceControl )
				bStopFlag = true;
		break;

		case WM_LBUTTONUP:
		case WM_LBUTTONDOWN:
		case WM_LBUTTONDBLCLK:
		case WM_RBUTTONUP:
		case WM_RBUTTONDOWN:
		case WM_RBUTTONDBLCLK:
		case WM_MBUTTONUP:
		case WM_MBUTTONDOWN:
		case WM_MBUTTONDBLCLK:
		case WM_NCLBUTTONUP:
		case WM_NCLBUTTONDOWN:
		case WM_NCLBUTTONDBLCLK:
		case WM_NCRBUTTONUP:
		case WM_NCRBUTTONDOWN:
		case WM_NCRBUTTONDBLCLK:
		case WM_NCMBUTTONUP:
		case WM_NCMBUTTONDOWN:
		case WM_NCMBUTTONDBLCLK:
		case WM_CONTEXTMENU:
			if(		msg.hwnd != m_hWndInplaceControl
				&&	(!::IsChild( m_hWndInplaceControl, msg.hwnd ))
				)
				bStopFlag = true;
		break;
		default:
//			if(	   msg.message == WM_SYSKEYDOWN
//				|| msg.message == WM_SYSKEYUP
//				|| msg.message == WM_KEYDOWN
//				|| msg.message == WM_KEYUP
//				)
//			{
//				bool bKeyUp =
//					( msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP )
//						? true : false;
//				BOOL bCtrl = ::GetKeyState(VK_CONTROL) & 0x80000000;
//				BOOL bShift = ::GetKeyState(VK_SHIFT) & 0x80000000;
//				//BOOL bAlt = HIWORD(msg.lParam) & KF_ALTDOWN;
//				TCHAR vkTCHAR = (TCHAR)msg.wParam;
//				if(			vkTCHAR == VK_MENU
//						&&	(!bCtrl) && (!bShift)
//						//&&	bKeyUp
//					)
//					bStopFlag = true;
//				//else if(	bAlt
//				//		&&	(	vkTCHAR == VK_SUBTRACT
//				//			||	vkTCHAR == VK_SPACE
//				//			)
//				//	)
//				//	bStopFlag = true;
//			}
			if(		( ! bStopFlag )
				&&	WM_KEYFIRST <= msg.message
				&&	msg.message <= WM_KEYLAST
				&&	(	msg.hwnd != m_hWndInplaceControl 
					||	(!::IsChild( m_hWndInplaceControl, msg.hwnd )) 
					)
				)
			{
				bool bAlt =
					( (::GetAsyncKeyState(VK_MENU)&0x8000) != 0 )
						? true : false;
				bool bCtrl =
					( (::GetAsyncKeyState(VK_CONTROL)&0x8000) != 0 )
						? true : false;
				bool bShift =
					( (::GetAsyncKeyState(VK_SHIFT)&0x8000) != 0 )
						? true : false;
				if( ! bAlt )
				{
					if(		bCtrl
						&&	(!bShift)
						&&	(	int(msg.wParam) == VK_INSERT
							||	int(msg.wParam) == int( _T(’C’) )
							)
						)
					{
						LRESULT lResult = 0L;
						g_pEditCell->OnInplaceControlWindowProc(
							lResult,
							msg.message,
							msg.wParam,
							msg.lParam,
							msg.hwnd,
							*this,
							nVisibleColNo,
							nVisibleRowNo,
							nColNo,
							nRowNo,
							nColType,
							nRowType,
							rcCellExtra,
							rcCell,
							rcInplaceControl
							);
						::PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
						if( msg.message == WM_KEYDOWN )
							::SendMessage( msg.hwnd, WM_COPY, 0, 0 );
						continue;
					} 
					if(		( bCtrl && (!bShift) && int(msg.wParam) == int( _T(’V’) ) )
						||	( (!bCtrl) && bShift && int(msg.wParam) == VK_INSERT )
						)
					{
						LRESULT lResult = 0L;
						g_pEditCell->OnInplaceControlWindowProc(
							lResult,
							msg.message,
							msg.wParam,
							msg.lParam,
							msg.hwnd,
							*this,
							nVisibleColNo,
							nVisibleRowNo,
							nColNo,
							nRowNo,
							nColType,
							nRowType,
							rcCellExtra,
							rcCell,
							rcInplaceControl
							);
						::PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
						if( msg.message == WM_KEYDOWN )
							::SendMessage( msg.hwnd, WM_PASTE, 0, 0 );
						continue;
					} 
					if(		( bCtrl && (!bShift) && int(msg.wParam) == int( _T(’X’) ) )
						||	( (!bCtrl) && bShift && int(msg.wParam) == VK_DELETE )
						)
					{
						LRESULT lResult = 0L;
						g_pEditCell->OnInplaceControlWindowProc(
							lResult,
							msg.message,
							msg.wParam,
							msg.lParam,
							msg.hwnd,
							*this,
							nVisibleColNo,
							nVisibleRowNo,
							nColNo,
							nRowNo,
							nColType,
							nRowType,
							rcCellExtra,
							rcCell,
							rcInplaceControl
							);
						::PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
						if( msg.message == WM_KEYDOWN )
						{
							if( ( g_pEditCell->GetStyle() & __EGCS_READ_ONLY ) == 0 )
								::SendMessage( msg.hwnd, WM_CUT, 0, 0 );
							else
								::SendMessage( msg.hwnd, WM_COPY, 0, 0 );
						}
						continue;
					} 
					if(	bCtrl && (!bShift) && int(msg.wParam) == int( _T(’A’) ) ) 
					{
						LRESULT lResult = 0L;
						g_pEditCell->OnInplaceControlWindowProc(
							lResult,
							msg.message,
							msg.wParam,
							msg.lParam,
							msg.hwnd,
							*this,
							nVisibleColNo,
							nVisibleRowNo,
							nColNo,
							nRowNo,
							nColType,
							nRowType,
							rcCellExtra,
							rcCell,
							rcInplaceControl
							);
						::PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
						if( msg.message == WM_KEYDOWN )

							::SendMessage( msg.hwnd, EM_SETSEL, 0, -1 );
						continue;
					}
					if(	(!bCtrl) && (!bShift) && int(msg.wParam) == VK_DELETE )
					{
						if( msg.message != WM_CHAR )
						{
							LRESULT lResult = 0L;
							g_pEditCell->OnInplaceControlWindowProc(
								lResult,
								msg.message,
								msg.wParam,
								msg.lParam,
								msg.hwnd,
								*this,
								nVisibleColNo,
								nVisibleRowNo,
								nColNo,
								nRowNo,
								nColType,
								nRowType,
								rcCellExtra,
								rcCell,
								rcInplaceControl
								);
							::PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
							if( msg.message == WM_KEYDOWN )
							{
								LPTSTR strEmpty = _T(""); 
								INT nSelStart = 0, nSelEnd = 0;
								::SendMessage( msg.hwnd, EM_GETSEL, reinterpret_cast < WPARAM > ( &nSelStart ), reinterpret_cast < LPARAM > ( &nSelEnd ) );
								if( nSelStart == nSelEnd )
									::SendMessage( msg.hwnd, EM_SETSEL, WPARAM( nSelStart ), LPARAM( nSelStart + 1 ) );
								if( ( g_pEditCell->GetStyle() & __EGCS_READ_ONLY ) == 0 )
									::SendMessage( msg.hwnd, EM_REPLACESEL, 1, reinterpret_cast < LPARAM > ( strEmpty ) );
							}
							continue;
						}
					}
				} // if( ! bAlt )
				if(		( (!bAlt) && bCtrl && (!bShift) && int(msg.wParam) == int( _T(’Z’) ) )
					||	( bAlt && (!bCtrl) && (!bShift) && int(msg.wParam) == VK_BACK )
					)
				{
					LRESULT lResult = 0L;
					g_pEditCell->OnInplaceControlWindowProc(
						lResult,
						msg.message,
						msg.wParam,
						msg.lParam,
						msg.hwnd,
						*this,
						nVisibleColNo,
						nVisibleRowNo,
						nColNo,
						nRowNo,
						nColType,
						nRowType,
						rcCellExtra,
						rcCell,
						rcInplaceControl
						);
					::PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
					if( msg.message == WM_KEYDOWN )
						::SendMessage( msg.hwnd, WM_UNDO, 0, 0 );
					continue;
				} 
			}
		break;
		} // switch( msg.message )

		if( bStopFlag )
 			break;
		if( ! pThread->PumpMessage() )
 			break;

	} // in-place editor message loop
	
	g_pEditCell = NULL;
	if( ! ::IsWindow( hWndGrid ) )
		return true;
	ASSERT( CWnd::FromHandlePermanent(hWndGrid) == this );
	ASSERT_VALID( this );
	m_nHelperLastEditedColNo = -1L;
	m_nHelperLastEditedRowNo = -1L;
	if( m_hWndInplaceControl != NULL )
	{
		if( ::IsWindow(m_hWndInplaceControl) )
		{
			if( ::GetCapture() == m_hWndInplaceControl )
				::ReleaseCapture();
			::ShowWindow( m_hWndInplaceControl, SW_HIDE );
			::SetFocus( m_hWnd ); // after changing focus inplace control kill itself
			// ::DestroyWindow( m_hWndInplaceControl );
		} // if( ::IsWindow(m_hWndInplaceControl) )
		m_hWndInplaceControl = NULL;
	} // if( m_hWndInplaceControl != NULL )
	return true;
}

Richard Rodruck Oct 17, 2007 - 5:05 PM

The delete key still doesn’t get there. It gets handled in the CExtGridInplaceEdit message loop in ExtGridWnd.cpp and no where else

Technical Support Oct 17, 2007 - 12:17 PM

You should override CExtGridCell::OnInplaceControlWindowProc() in your CExtGridCell-derived class or override the CExtGridWnd::OnGridCellInplaceControlWindowProc() virtual method in your CExtGridWnd-derived class. This will allow you to watch for the messages of the in-place active editor control.