?
Solved

ownerdraw clistctrl assert

Posted on 2006-05-04
3
Medium Priority
?
935 Views
Last Modified: 2013-11-20
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);
}
0
Comment
Question by:cophi
  • 2
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16609076
>>I'm getting an Assesition error

Where exactly?
0
 

Author Comment

by:cophi
ID: 16609336
Oh sorry in the CListCtrl DrawItem
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 16609384
That's not surprising, since the code for that function is

void CListCtrl::DrawItem(LPDRAWITEMSTRUCT)
{
    ASSERT(FALSE);
}

You should not call the base class implementation here, only provide your own implementation. As the docs state:

"By default, this member function does nothing. Override this member function to implement drawing for an owner-draw CListCtrl object."
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Screencast - Getting to Know the Pipeline
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question