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.
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>...
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.
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
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.