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 |
|
park ki tae
|
Mar 25, 2010 - 11:02 PM
|
BOOL CPageListCtrl::OnInitDialog() { .... INT nColumnCount = 5, nColumnIndex;
for( nColumnIndex = 0; nColumnIndex < nColumnCount; nColumnIndex ++ )
{
CExtSafeString strColumnCaptionText;
// strColumnCaptionText.Format( _T("Column %02d"), nColumnIndex ); strColumnCaptionText.Format( _T("%d"), nColumnIndex );
m_wndList.InsertColumn( nColumnIndex, strColumnCaptionText, LVCFMT_LEFT, 150 );
} .... } i changed the code above and complie in WIN32 MBCS Mode and run. then the program is crashed when i click ListView Button but in VC 7.1, there is no problem.
|
|
Technical Support
|
Mar 26, 2010 - 9:39 AM
|
Thank you for reporting this issue. You can fix it by updating the following two methods:
void CExtHeaderCtrl::OnPaint()
{
ASSERT_VALID( this );
CRect rcClient;
GetClientRect( &rcClient );
CPaintDC dcPaint( this );
CExtMemoryDC dc( &dcPaint, &rcClient );
OnEraseHeaderBackground( dc, rcClient );
INT nColNo, nColCount = INT(GetItemCount());
for( nColNo = 0; nColNo < nColCount; nColNo++ )
{
CRect _rcItemEntire;
if( ! GetItemRect( nColNo, &_rcItemEntire ) )
continue;
if( ! dc.RectVisible( &_rcItemEntire ) )
continue;
HD_ITEM _item;
::memset( &_item, 0, sizeof(HD_ITEM) );
_item.mask = UINT(-1);
TCHAR strText[ 1024 ];
::memset( strText, 0, sizeof(strText) );
_item.cchTextMax = sizeof( strText ) / sizeof( strText[0] );
_item.pszText = strText;
GetItem( nColNo, &_item );
OnPaintHeaderItem( dc, _item, nColNo, _rcItemEntire );
}
}
CSize CExtHeaderCtrl::OnCalcHeaderItemSize(
INT nColNo
) const
{
ASSERT_VALID( this );
if( GetSafeHwnd() == NULL )
return CSize( 0, 0 );
INT nColCount = INT( GetItemCount() );
ASSERT( 0 <= nColNo && nColNo < nColCount );
CExtPaintManager * pPM = PmBridge_GetPM();
ASSERT_VALID( pPM );
const EXTENDED_ITEM_DATA & _eii = ExtendedItemDataGet( nColNo );
CSize _sizeEntireItem( 0, 0 );
if( ! _eii.m_iconButton.IsEmpty() )
{
CSize sizeButton = _eii.m_iconButton.GetSize();
INT nButtonPaddingBefore = 0, nButtonPaddingAfter = 0;
pPM->Header_GetButtonPadding( nButtonPaddingBefore, nButtonPaddingAfter, nColNo, nColCount, (CObject*)this );
sizeButton.cx += nButtonPaddingBefore + nButtonPaddingAfter;
_sizeEntireItem.cx += sizeButton.cx;
_sizeEntireItem.cy = max( _sizeEntireItem.cy, sizeButton.cy );
}
if( ! _eii.m_iconItem.IsEmpty() )
{
INT nBetweenIconAndText = pPM->Header_GetDistanceBetweenIconAndText( nColNo, nColCount, (CObject*)this );
CSize _sizeIcon = _eii.m_iconItem.GetSize();
_sizeIcon.cx += nBetweenIconAndText;
_sizeEntireItem.cx += _sizeIcon.cx;
_sizeEntireItem.cy = max( _sizeEntireItem.cy, _sizeIcon.cy );
}
INT nSortRuleNo = m_sortOrder.GetColPos( nColNo );
if( nSortRuleNo >= 0 )
{
INT nBetweenIconAndSortArrow = pPM->Header_GetDistanceBetweenIconAndSortArrow( nColNo, nColCount, (CObject*)this );
INT nSortArrowExtent = pPM->Header_GetSortArrowWidth( nColNo, nColCount, (CObject*)this );
_sizeEntireItem.cx += nSortArrowExtent + nBetweenIconAndSortArrow;
}
HD_ITEM _item;
::memset( &_item, 0, sizeof(HD_ITEM) );
_item.mask = UINT(HDI_TEXT);
TCHAR strText[ 1024 ];
::memset( strText, 0, sizeof(strText) );
_item.cchTextMax = sizeof( strText ) / sizeof( strText[0] );
_item.pszText = strText;
GetItem( nColNo, &_item );
CExtSafeString s;
s = _item.pszText;
CFont * pFont = &pPM->m_FontNormal; //GetFont();
if( pFont->GetSafeHandle() == NULL )
pFont = &(pPM->m_FontNormal);
CClientDC dc( (CWnd*)this );
CSize _sizeText = CExtPaintManager::stat_CalcTextDimension( dc, *pFont, s ).Size();
_sizeEntireItem.cx += _sizeText.cx;
_sizeEntireItem.cy = max( _sizeEntireItem.cy, _sizeText.cy );
CRect rcItemPadding = pPM->Header_GetItemPadding( nColNo, nColCount, (CObject*)this );
_sizeEntireItem.cx += rcItemPadding.left + rcItemPadding.right;
_sizeEntireItem.cy += rcItemPadding.top + rcItemPadding.bottom;
return _sizeEntireItem;
}
|
|