I am using a C++ source code generator from Computer Associates, called
Allfusion Plex, and need to insert source code to set focus on the next
editable cell in a grid. For example, I have a maintenable grid with four
columns. The first column is read only and tab stop is set to No. The
second and third columns are editable and tab stop is set to Yes. The
fourth and last column is editable but the tab stop is to No. I am
currently using source code to trap the tab key pressed event. I need the
source code to set focus to the next editable column with tab stop yes,
which can be on the next row if the cursor is in the last editable column in
the current row. Also, I will need to be able to tab backwards. Here is an
example of the source code I am using but it does not work as previously
described.
{
// 1. Get Current Message for Trapped Control
MSG *pMessage = ObAppAPI::GetCurrentMessage();
int iNtfcCode = HIWORD( pMessage->wParam );
if( iNtfcCode == HGN_SELCHANGING ){
// 2. Get Key Pressed State for Needed Keys
int iShftKey = 0;
if( GetKeyState(VK_SHIFT) & 0x80 ){
iShftKey = 1;
}
int iPrsdKey = 0;
if( GetKeyState(VK_TAB) & 0x80 ){
iPrsdKey = VK_TAB;
}else{ if( GetKeyState(VK_RETURN) & 0x80 ){
iPrsdKey = VK_RETURN;
}else{ if( GetKeyState(VK_F5) & 0x80 ){
iPrsdKey = VK_F5;
}else{ if( GetKeyState(VK_F6) & 0x80 ){
iPrsdKey = VK_F6;
} }}}
// 3. Process User Input
if( iPrsdKey != 0 ){
HWND HwndGrid=ObPanelAPI::GetControlHandleByName(&(1:)) ;
if (HwndGrid){
LONG lCurCell = HGGetCurSel(HwndGrid);
int iCurCol = CELLCOL( lCurCell );
int iCurRow = CELLROW( lCurCell );
int iColCnt = SendMessage(HwndGrid, HGM_GETCOLCOUNT, 0, 0L);
int iRowCnt = SendMessage(HwndGrid, HGM_GETROWCOUNT, 0, 0L);
unsigned long lMarker = SendMessage(HwndGrid, HGM_GETMARKER, 0, 0L);
int iMarCol, iMarRow;
iMarCol = LOWORD(lMarker);
iMarRow = HIWORD(lMarker);
if( iPrsdKey == VK_TAB ){
if( iColCnt == (iCurCol+1) ){
if( iCurCol == iMarCol ){
iMarCol = 0;
if( ++iMarRow >= iRowCnt ){ iMarRow = 0; }
HGSetCurSel(HwndGrid, iMarCol, iMarRow);
}}
}else{ if( iPrsdKey == VK_RETURN ){
iMarCol = 0;
HGSetCurSel(HwndGrid, iMarCol, iMarRow);
} }
}
}
}
}