Re: How do you use a derived CListCtrl in a dialog based MFC application? by aualias
aualias
Sun May 09 19:44:27 CDT 2004
Scott,
Thanks. That works perfectly.
AU
"Scott McPhillips [MVP]" <scottmcp@mvps.org.nothere> wrote in message
news:efV1DlgNEHA.1608@TK2MSFTNGP12.phx.gbl...
> aualias wrote:
> > I have derived a class from CListCtrl in a dialog based app. I want to
be
> > able to use alternating colors for rows.
> >
> > When I use the designer, I create a ListView that I can access using
> > GetDlgItem(the_id). If I use
> > m_pListCtrl = (CMyListCtrl *) GetDlgItem(IDC_LIST);
> > the constructor does not get called, and none of the overridden methods
get
> > called, because the object already has been constructed before I make
the
> > assignment.
> >
> > How do I get the dialog to use my CMyListCtrl when the ListView is
> > constructed? Is it even possible to use the designer when doing this?
> >
> > Thanks.
> >
> > AU
>
> Derive your class from CListCtrl and use class wizard to add a control
> member variable of your derived class to the dialog. When you do this
> Class wizard adds a DDX_Control call that "connects" your class to the
> control. The result is that all messages sent to the control can be
> intercepted in the message map of your class.
>
> --
> Scott McPhillips [VC++ MVP]
>