Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trapping Column Sizing of CListCtrl in Report view?

287 views
Skip to first unread message

David Kuik

unread,
Apr 30, 1997, 3:00:00 AM4/30/97
to

Hi all.

Does anybody have some sample code on trapping the
column resizing messages of the CListCtrl in Report View.

I have a view derived from CListView in a SDI application
and I want to save the widths of the columns with the
data.

I tried handling the HDN_BEGINTRACK and HDN_ENDTRACK messages
in my view by using the following code but it doesn't work.
Any ideas?

BEGIN_MESSAGE_MAP(CMyListView, CListView)
ON_NOTIFY_REFLECT(HDN_BEGINTRACK,OnBeginTrack)
ON_NOTIFY_REFLECT(HDN_ENDTRACK,OnEndTrack)
END_MESSAGE_MAP

Thanks, Dave.

R.S. Baker

unread,
Apr 30, 1997, 3:00:00 AM4/30/97
to

I have subclassed both the CListCtrl and CHeaderCtrl and catch the
notification HDN_ITEMCHANGED in the CHeaderCtrl subclass via
ON_NOTIFY_REFLECT. Since the CListCtrl is the parent of th CHeaderCtrl, you
could catch the notification in your CMyListView class, too.

In the HDN_ITEMCHANGED notification, I do the following to detect changes
to column widths:

HD_NOTIFY* pNMListHdr = (HD_NOTIFY*)pNMHDR;
if (pNMListHdr->pitem->mask & HDI_WIDTH)
{
TRACE("Width of header %d changed: %d\n", pNMListHdr->iItem,
pNMListHdr->pitem->cxy);

// Insert code to handle column width here
}


--
Randy

(Please remove .NOSPAM if replying via email)

David Kuik <dk...@online.mb.ca> wrote in article
<33676E...@online.mb.ca>...

R.S. Baker

unread,
Apr 30, 1997, 3:00:00 AM4/30/97
to

I didn't mention this in my other post, but since the CHeaderCtrl is a
child of the CListCtrl, you probably want to use ON_NOTIFY instead of
ON_NOTIFY_REFLECT. You would use ON_NOTIFY_REFLECT to handle the
CHeaderCtrl notifications within a derived class of CHeaderCtrl.

David Kuik

unread,
May 1, 1997, 3:00:00 AM5/1/97
to

Hi Randy.

I can't use the ON_NOTIFY macro because I don't have an ID for the
header control. The header control is a child of the list control
which is associated with my list view class derived from CListView.
Is there a way to get the id, or can you expand?

Much appreciated.

Dave.

David Kuik

unread,
May 1, 1997, 3:00:00 AM5/1/97
to

I added a message handler for the reflected HDN_ITEMCHANGED message using
ClassWizard, but the handler never gets called, just like my HDN_BEGINTRACK
and HDN_ENDTRACK handlers. Is there a way to tell the list control to
pass the message on to the view? The list control seems to be handling
the HDN_* messages without reflecting them to the view.

Frustratedly yours,
Dave


R.S. Baker wrote:
>
> I have subclassed both the CListCtrl and CHeaderCtrl and catch the
> notification HDN_ITEMCHANGED in the CHeaderCtrl subclass via
> ON_NOTIFY_REFLECT. Since the CListCtrl is the parent of th CHeaderCtrl, you
> could catch the notification in your CMyListView class, too.
>
> In the HDN_ITEMCHANGED notification, I do the following to detect changes
> to column widths:
>
> HD_NOTIFY* pNMListHdr = (HD_NOTIFY*)pNMHDR;
> if (pNMListHdr->pitem->mask & HDI_WIDTH)
> {
> TRACE("Width of header %d changed: %d\n", pNMListHdr->iItem,
> pNMListHdr->pitem->cxy);
>
> // Insert code to handle column width here
> }
>

Justin Rudd

unread,
May 1, 1997, 3:00:00 AM5/1/97
to

You can derive a class from CHeaderCtrl and subclass the header
yourself.

Justin
Stingray Software

David Kuik wrote:
>
> Hi Randy.
>
> I can't use the ON_NOTIFY macro because I don't have an ID for the
> header control. The header control is a child of the list control
> which is associated with my list view class derived from CListView.
> Is there a way to get the id, or can you expand?
>
> Much appreciated.
>
> Dave.
>
> R.S. Baker wrote:
> >
> > I didn't mention this in my other post, but since the CHeaderCtrl is a
> > child of the CListCtrl, you probably want to use ON_NOTIFY instead of
> > ON_NOTIFY_REFLECT. You would use ON_NOTIFY_REFLECT to handle the
> > CHeaderCtrl notifications within a derived class of CHeaderCtrl.

0 new messages