|
|
|
|
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.
Subject |
Author |
Date |
|
Eike Loch
|
Nov 11, 2004 - 10:01 AM
|
I would like use keyevents, e.g. Tab select the next cell. The ’OnGbwAnalyzeCellKeyEvent’ -method catch the event , but not, if the InplaceEdit is active. How i can close the edit-mode and send the message to the grid.
|
|
Technical Support
|
Nov 12, 2004 - 2:56 AM
|
Dear Eike,
Thank you for the interesting question. What you need is can be easily done. Just create a class derived from CExtGridWnd and override the PreTranslateMessage virtual method like this:BOOL CYourGridWnd::PreTranslateMessage( MSG * pMsg )
{
if( pMsg->message == WM_KEYDOWN
&& pMsg->wParam == VK_TAB
)
{
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 || bCtrl ) )
{
LONG nColCount = ColumnCountGet();
LONG nRowCount = RowCountGet();
if( nColCount > 1 && nRowCount > 0 )
{
CPoint ptFocus = FocusGet();
if( ptFocus.x >= 0 && ptFocus.y >= 0 )
{
CPoint ptNewFocus = ptFocus;
if( bShift )
{
if( ptFocus.x > 0 )
ptNewFocus.x --;
} // if( bShift )
else
{
if( ptFocus.x < (nColCount-1) )
ptNewFocus.x ++;
} // else from if( bShift )
if( ptNewFocus != ptFocus )
{
bool bContinueEdit = false;
CWnd * pWndFocus =
CWnd::GetFocus();
if( pWndFocus != NULL
&& pWndFocus->IsKindOf(
RUNTIME_CLASS(
CExtGridInplaceEdit
)
)
)
bContinueEdit = true;
SendMessage( WM_CANCELMODE );
FocusSet( ptNewFocus );
if( bContinueEdit )
EditCell();
} // if( ptNewFocus != ptFocus )
} // if( ptFocus.x >= 0 && ptFocus.y >= 0 )
} // if( nColCount > 1 && nRowCount > 0 )
} // if( !( bAlt || bCtrl ) )
return TRUE;
}
return CExtGridWnd::PreTranslateMessage( pMsg );
} Now, when you are in the edit mode, your grid supports switching between cells in a row with Tab or Shift+Tab keys.
|
|
Cyndi Chatman
|
Feb 14, 2007 - 10:25 AM
|
If I have a changed a cell to read only, by doing the following:
pCell->ModifyStyle( __EGCS_NO_INPLACE_CONTROL);
how can I skip read-only cells when the TAB key is pressed?
It would seem that I need to go into a while loop after calling FocusSet(pNewFocus) and can determine if it is read only by calling GetStyle()?
|
|
Technical Support
|
Feb 14, 2007 - 12:33 PM
|
By default, you cannot skip read-only cells. You can change this behavior only by overriding CExtGridBaseWnd::OnGbwAnalyzeCellKeyEvent() .
|
|