CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 1999
    Posts
    6

    CListView::DrawItem() never called

    For whatever reason, I cant get the framework to call DrawItem. I have set the style bits as follows:


    BOOL CTransactionView::PreCreateWindow(CREATESTRUCT& cs)
    {

    //cs.style &= ~LVS_TYPEMASK;
    //cs.style &= ~LVS_SHOWSELALWAYS;
    //cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED;
    //cs.style |= LVS_EDITLABELS;

    return CListView::PreCreateWindow(cs);
    }




    What am I doing wrong?

    Scott


  2. #2
    Join Date
    Jun 1999
    Posts
    15

    Re: CListView::DrawItem() never called

    Hi Scott,

    I ended up using a class from one of the examples in MSDN. The class is called CListViewEx and it's included in an example called RowList. Its PreCreateWindow doesn't look much different than yours, but fwiw here it is:



    BOOL CListViewEx::PreCreateWindow(CREATESTRUCT& cs)
    {
    // default is report view and full row selection
    cs.style &= ~LVS_TYPEMASK;
    cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED;
    m_bFullRowSel = TRUE;

    return(CListView::PreCreateWindow(cs));
    }





    I guess I'm not much help for you, but it may give you another avenue to go down...

    Curt




  3. #3
    Join Date
    Apr 1999
    Location
    Bangalore, India
    Posts
    25

    Re: CListView::DrawItem() never called

    There is really no need to use CListViewEx. Although the example in the rowlist solves the problem, but the objective of rowlist is to demonstrate the implementation of ownerdrawn CListCtrl. Full row selction has become very very by using LVS_EX_FULLROWSELECT extended style.
    DrawItem() can be called for CListView as well as a CListCtrl in a dialog or a CFormView. The only difference being that in FormView or Dialog you have to override OnDrawItem().


  4. #4
    Join Date
    Apr 1999
    Location
    Bangalore, India
    Posts
    25

    Re: CListView::DrawItem() never called

    You have to set LVS_OWNERDRAWFIXED. Otherwise you won't get DrawItem().


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured