Fix resizing problem in above article


Override CListCtrl::OnNotify as follows :

BOOL CMyListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT*pResult) 
{
  HD_NOTIFY *pHD = (HD_NOTIFY*)lParam;

  if ((pHD->hdr.code == HDN_ITEMCHANGINGA || pHD->hdr.code == HDN_ITEMCHANGINGW) && (GetStyle() & LVS_TYPEMASK) == LVS_REPORT)
  { // Invalidate empty bottom part of control to force erase the previous position of column
    int nBottom,nLastItem=GetItemCount()-1;
    if (nLastItem<0)
      nBottom=0; // List is empty : invalidate whole client rect
    else
    { // Get Y position of bottom of list (last item)
      RECT ItemRect;
      GetItemRect(nLastItem,&ItemRect,LVIR_BOUNDS);
      nBottom=ItemRect.bottom;
    }
    
    RECT rect;
    GetClientRect(&rect);
    if (nBottom<rect.bottom)
    { // Set top of rect as bottom of list (last item) : rect = empty part of list
      rect.top=nBottom;
      InvalidateRect(&rect);
    }

    // NB: We must to on with default processing.
  }

  *pResult = 0;
  return CListCtrl::OnNotify(wParam, lParam, pResult);
}

Simply adding a HDN_ITEMCHANGING or HDN_TRACK handler with
ClassWizarddoesn't work. These handlers are not called. Why ???
I noticed that class wizard places an ON_NOTIFY_REFLECT(...) entry for
these notifications. I'd rather put an ON_NOTIFY(...) since the
notification comes from the header control to its parent (the listctrl).
But Spy++ shows that the CtrlID of the header is 0. repplacing the
ON_NOTIFY_REFLECT entry by ON_NOTIFY(HDN_xxx,0,f) didn't solve the
problem. That's why I chose to override OnNotify()



Comments

  • Column resizing

    Posted by Legacy on 04/22/1999 12:00am

    Originally posted by: Srinivas Bandi

    I have problems when resizing the column, the right side of the control is not repainted. Is there any fix for this problem. Please let me know if you have any update.

    Reply
  • CListCtrl Redraw of grid lines on Scrolling

    Posted by Legacy on 04/01/1999 12:00am

    Originally posted by: Dharmesh Sethi

    I am having a very similar problem. Similar barcode-like lines appear when I use the horizontal scroll bar. I am using an owner draw version of a CListCtrl derived class. If anyone has any solutions/suggestions pls let me know.

    Otherwise is there any way for me to use the LVS_EX_GRIDLINES extended style for the CListCtrl and then change the color of the grid lines.

    Thanks for any help,
    dharmesh_sethi@rsco.com

    Reply
  • This doesn't work for views.

    Posted by Legacy on 03/02/1999 12:00am

    Originally posted by: Bill Foust

    No complaints, just an FYI. If you are using CListViews, this solution doesn't
    work. I ended up calling OnEraseBkgnd() in OnPaint(). Probably not the best
    solution, but it works. :)

    Bill

    Reply
  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Wednesday, September 24, 2014 8:00 AM - 9:00 AM PDT According to a recent Forrester Research report, many companies are choosing low-code platforms over traditional programming platforms, due to the speed with which low-code apps can be assembled and tested. With customer-facing applications on the rise, traditional programming platforms simply can't keep up with the "short schedules and rapid change cycles" required to develop these applications. Check out this upcoming webinar and join Clay Richardson from …

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds