|
|
|
|
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 |
|
Gunasekaran Velu
|
Oct 5, 2005 - 5:40 AM
|
hi folks i want to move the cursor from one column to next column when tab key is pressed in CExtGridCell? thanks in Advance Guna
|
|
Gunasekaran Velu
|
Oct 6, 2005 - 1:03 AM
|
hi i tried this code but i didn’t get. ok is this function available in CExtGridCell or not ? reply soon Thanks GUna
|
|
Technical Support
|
Oct 6, 2005 - 10:38 AM
|
We are sorry, you need to override the PreTranslateMessage virtual method in a CExtGridWnd -derived class and handle the WM_KEYDOWN standard Windows message. This method may look like: BOOL CDemoGrid::PreTranslateMessage( MSG * pMsg )
{
ASSERT_VALID( this );
if( pMsg->message == WM_KEYDOWN
&& pMsg->wParam == VK_TAB
)
{
bool bShift =
( (::GetAsyncKeyState(VK_SHIFT)&0x8000) != 0 ) ? true : false;
LONG nRowCount = RowCountGet();
LONG nColCount = ColumnCountGet();
if( nRowCount == 0 || nColCount == 0 )
return TRUE;
CPoint ptFocusOld = FocusGet();
CPoint ptFocusNew = ptFocusOld;
if( ptFocusNew.y < 0 )
ptFocusNew.x = ptFocusNew.y = 0;
else if( ptFocusNew.x == ( nColCount - 1 ) && !bShift )
{
ptFocusNew.x = 0;
ptFocusNew.y += ( bShift ? -1 : +1 );
}
else if( ptFocusNew.x == 0 && bShift )
{
ptFocusNew.x = nColCount - 1;
ptFocusNew.y -= 1;
}
else
ptFocusNew.x += ( bShift ? -1 : +1 );
if( ptFocusNew.y < 0 || ptFocusNew.x < 0 )
ptFocusNew.y = ptFocusNew.x = 0;
if( ptFocusNew.y > nRowCount - 1 || ptFocusNew.x > nColCount - 1 )
{
ptFocusNew.y = nRowCount - 1;
ptFocusNew.x = nColCount - 1;
}
if( ptFocusOld != ptFocusNew )
FocusSet( ptFocusNew );
return TRUE;
}
return CExtGridWnd::PreTranslateMessage( pMsg );
}
|
|
Gunasekaran Velu
|
Oct 6, 2005 - 11:48 PM
|
this is my code class CManagedTabPageContainer : public CExtTabPageContainerFlatWnd { class CManagedTabWnd : public CExtTabFlatWnd { int m_nShift; int m_nSize; public: CManagedTabWnd(){ m_nShift=-1; m_nSize=-1; } int GetShift(){ CRect rc; GetWindowRect(rc); return _CalcRgnShift( OrientationIsHorizontal(), rc ); } int GetSize(){ return OnFlatTabWndGetSize( OrientationIsHorizontal() ); } void SetShift( int nShift ){ m_nShift = nShift; } void SetSize( int nSize ){ m_nSize = nSize; } protected: virtual int _CalcRgnShift( bool bHorz, const CRect & rc ) { int nShift = 0; if( m_nShift >= 0 ) nShift = m_nShift; else nShift = ::MulDiv( bHorz ? rc.Height() : rc.Width(), 1, 4 ); return nShift; } virtual int OnFlatTabWndGetSize( bool bHorz ) { int nSize = 0; if(bHorz) if( m_nSize > 0 ) nSize = m_nSize; else nSize = 16;//::GetSystemMetrics( SM_CXHSCROLL ); else if( m_nSize > 0 ) nSize = m_nSize; else nSize = 16;//::GetSystemMetrics( SM_CYHSCROLL ); return nSize; } }; // class CManagedTabWnd virtual CExtTabWnd* OnTabWndGetTabImpl(){ return new CExtTWPC < CManagedTabWnd >; } virtual bool OnTabWndClickedButton( LONG nHitTest, bool bButtonPressed, INT nMouseButton, // MK_... values UINT nMouseEventFlags) { ASSERT_VALID( this ); nMouseButton; nMouseEventFlags; if( nHitTest==__ETWH_BUTTON_CLOSE && !bButtonPressed ){ CString s; s.Format(_T("\"Close\" button clicked on page - %d"), PageSelectionGet()); AfxMessageBox(s); } if( nHitTest==__ETWH_BUTTON_HELP && !bButtonPressed ){ CString s; s.Format(_T("\"Help\" button clicked on page - %d"), PageSelectionGet()); AfxMessageBox(s); } Invalidate(); return true; } public: void SetShift( int nShift ){ ((CManagedTabWnd*)m_pWndTab)->SetShift( nShift ); ((CManagedTabWnd*)m_pWndTab)->UpdateTabWnd(); } void SetSize( int nSize ){ ((CManagedTabWnd*)m_pWndTab)->SetSize( nSize ); ((CManagedTabWnd*)m_pWndTab)->UpdateTabWnd(); _RepositionBarsImpl(); } int GetShift(){ return ((CManagedTabWnd*)m_pWndTab)->GetShift(); } int GetSize(){ return ((CManagedTabWnd*)m_pWndTab)->GetSize(); } }; // class CManagedTabPageContainer the above code in MainFrm.h in my pgm.i have overwrite the OnTabWndClickedButton() method( see above) but when i debug the pgm and i clicked the tab menu but the should not fire the OnTabWndClickedButton() this function. can u help me.
|
|
Gunasekaran Velu
|
Oct 6, 2005 - 11:51 PM
|
sorry for the unwanted code.(this for tab cicked problem)
|
|
Technical Support
|
Oct 5, 2005 - 9:17 AM
|
Just create a CExtGridWnd -derived class and handle the WM_KEYDOWN standard Windows message. The OnKeyDown() handler should process the VK_TAB key and invoke the parent method for other keys. This method may look like: void CYourGridWnd::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
{
ASSERT_VALID( this );
if( nChar == VK_TAB )
{
LONG nRowCount = RowCountGet();
LONG nColCount = ColumnCountGet();
if( nRowCount == 0 || nColCount == 0 )
return;
CPoint ptFocusOld = FocusGet();
CPoint ptFocusNew = ptFocusOld;
if( ptFocusNew.y < 0 )
ptFocusNew.x = ptFocusNew.y = 0;
else if( ptFocusNew.x == (nColCount-1) )
return;
else
ptFocusNew.x ++;
if( ptFocusOld == ptFocusNew )
return;
FocusSet( ptFocusNew );
return;
}
CExtGridWnd::OnKeyDown( nChar, nRepCnt, nFlags)
}
|
|