|
|
|
|
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 |
|
Krustys Donuts
|
Sep 8, 2005 - 10:01 AM
|
Hi, in the past, you’ve instructed me to use the __EGCS_NO_INPLACE_CONTROL style to make my CExtGridCellComboBox subclasses act like a droplist control. Overall, it does function like a droplist, *however*, one of the nicest things about a true droplist is that you can make the list appear by clicking on the cell itself, instead of the "down arrow" button. Can you tell me how to modify the behavior of this class to act like this, or is it impossible because the NO_INPLACE_CONTROL style throws out mouse clicks in the cell’s editable area?
|
|
Technical Support
|
Sep 8, 2005 - 11:01 AM
|
Create a CExtGridCell -derived class and override the CExtGridCell::OnClick() virtual method in this way: bool CExtGridCell::OnClick(
CExtGridWnd & wndGrid,
const CExtGridHitTestInfo & htInfo,
UINT nChar,
UINT nRepCnt,
UINT nFlags
)
{
ASSERT_VALID( this );
if( nChar == VK_LBUTTON && ( nRepCnt == 1 || nRepCnt == 2 ) )
{
if( (nFlags&(MK_SHIFT|MK_CONTROL)) == 0 )
{
CExtGridHitTestInfo htInfoTrack( htInfo );
htInfo.m_dwAreaFlags |= __EGBWA_CELL_BUTTON;
htInfoTrack.m_nButtonType = (int)__EBTT_DROPDOWN;
return
wndGrid.OnGridTrackCellButton(
this,
htInfoTrack
);
}
}
return
CExtGridCell::OnClick(
wndGrid,
htInfo,
nChar,
nRepCnt,
nFlags
);
} That should implement the behavior that is expected.
|
|
Krustys Donuts
|
Sep 8, 2005 - 2:32 PM
|
Doesn’t work -- seems that OnClick is not a virtual method in the CExtGridCellComboBox class. It is for CExtGridCell and CExtGridCellHyperlink... but the combobox isn’t derived in any way from either of those two classes.
|
|
Technical Support
|
Sep 9, 2005 - 7:11 AM
|
Here is a ready-to-use CExtGridCellDropDownComboBox class:
CLASS DECLARATION: /////////////////////////////////////////////////////////////////////////////
// CExtGridCellDropDownComboBox
class CExtGridCellDropDownComboBox : public CExtGridCellComboBox
{
public:
DECLARE_SERIAL( CExtGridCellDropDownComboBox );
IMPLEMENT_ExtGridCell_Clone( CExtGridCellDropDownComboBox, CExtGridCellComboBox );
CExtGridCellDropDownComboBox(
CExtGridDataProvider * pDataProvider = NULL
);
virtual bool OnClick(
CExtGridWnd & wndGrid,
const CExtGridHitTestInfo & htInfo,
UINT nChar,
UINT nRepCnt,
UINT nFlags
);
}; // class CExtGridCellDropDownComboBox CLASS IMPLEMENTATION:IMPLEMENT_SERIAL( CExtGridCellDropDownComboBox, CExtGridCellComboBox, VERSIONABLE_SCHEMA|1 );
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExtGridCellDropDownComboBox
CExtGridCellDropDownComboBox::CExtGridCellDropDownComboBox(
CExtGridDataProvider * pDataProvider // = NULL
)
: CExtGridCellComboBox( pDataProvider )
{
}
bool CExtGridCellDropDownComboBox::OnClick(
CExtGridWnd & wndGrid,
const CExtGridHitTestInfo & htInfo,
UINT nChar,
UINT nRepCnt,
UINT nFlags
)
{
ASSERT_VALID( this );
ASSERT_VALID( (&wndGrid) );
ASSERT( ! htInfo.IsHoverEmpty() );
ASSERT( htInfo.IsValidRect() );
ASSERT( nChar == VK_LBUTTON || nChar == VK_RBUTTON || nChar == VK_MBUTTON );
ASSERT( 0 <= nRepCnt && nRepCnt <= 3 );
if( nChar == VK_LBUTTON && ( nRepCnt == 1 || nRepCnt == 2 ) )
{
if( (nFlags&(MK_SHIFT|MK_CONTROL)) == 0 )
{
CExtGridHitTestInfo htInfoTrack( htInfo );
htInfoTrack.m_dwAreaFlags |= __EGBWA_CELL_BUTTON;
htInfoTrack.m_nButtonType = (int)__EBTT_DROPDOWN;
return
wndGrid.OnGridTrackCellButton(
this,
htInfoTrack
);
}
}
return
CExtGridCellComboBox::OnClick(
wndGrid,
htInfo,
nChar,
nRepCnt,
nFlags
);
}
|
|