Link to home
Start Free TrialLog in
Avatar of cophi
cophi

asked on

ownerdraw clistctrl assert

I'm getting an Assesition error when I try to override the OwnerDrawn List Control.  Why would this be.  

// ---------------------
// -- CListCtrlStyled --
// ---------------------
class CListCtrlStyled : public CListCtrl
{
public:
     // -- Construction --
     //
     CListCtrlStyled();
     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);

....

void CListCtrlStyled::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
    TEXTMETRIC tm;
    HDC hDC = ::GetDC(NULL);
    CFont* pFont = GetFont();
    HFONT hFontOld = (HFONT)SelectObject(hDC, pFont->GetSafeHandle());
    GetTextMetrics(hDC, &tm);
    lpMeasureItemStruct->itemHeight = tm.tmHeight + tm.tmExternalLeading + 1;
    SelectObject(hDC, hFontOld);
    ::ReleaseDC(NULL, hDC);
}

void CListCtrlStyled::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
     CListCtrl::DrawItem(lpDrawItemStruct);
}
Avatar of jkr
jkr
Flag of Germany image

>>I'm getting an Assesition error

Where exactly?
Avatar of cophi
cophi

ASKER

Oh sorry in the CListCtrl DrawItem
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial