Header Ctrl changes in a CListView
David Doughty -- dave_doughty@MENTORG.COM
Wednesday, April 17, 1996
VC4.0/Win '95
I have derived a class from CListView and am attempting to receive
notifications when the user changes the header control. Specifically, when
the user resizes a column in the report view I'd like to take some action.
I have searched MSDN etc. and discovered a message HDN_ITEMCHANGED but
can't figure out how to intercept it or understand if that is the best
mechanism in MFC.
dal.ghotra@rebis.com
Friday, April 19, 1996
Try something like:
(Here my CMyListView was derived from CListView)
BOOL CMyListView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT*
pResult)
{
switch (((LPNMHDR)lParam)->code)
{
// The listview control passes along all the notifications
// sent to it by the header control when it is in report
// view.
case HDN_ENDTRACKW:
TRACE0("\nHeader end track - when user finishes dragging");
{
HD_NOTIFY *phdn = (HD_NOTIFY*)lParam;
// New width is (LPARAM)phdn->iItem)
}
break;
case HDN_BEGINTRACKW:
TRACE0("\nHeader begin track");
break;
case HDN_TRACKW:
TRACE0("\nHeader dynamic tracking");
break;
case HDN_ITEMCHANGEDW:
TRACE0("\nHeader item changed");
break;
case HDN_ITEMCHANGINGW:
TRACE0("\nHeader item changing");
break;
case HDN_ITEMCLICKW:
TRACE0("\nHeader click");
break;
case HDN_ITEMDBLCLICK:
TRACE0("\nHeader dblclick");
break;
}
return CListView::OnNotify(wParam, lParam, pResult);
}
The 'W' at the end of each message denotes the UNICODE versions.
dal.ghotra@rebis.com
______________________________ Reply Separator _________________________________
Subject: Header Ctrl changes in a CListView
Author: mfc-l@netcom.netcom.com at Internet
Date: 4/19/96 4:38 AM
VC4.0/Win '95
I have derived a class from CListView and am attempting to receive
notifications when the user changes the header control. Specifically, when
the user resizes a column in the report view I'd like to take some action.
I have searched MSDN etc. and discovered a message HDN_ITEMCHANGED but
can't figure out how to intercept it or understand if that is the best
mechanism in MFC.
Niels Ull Jacobsen -- nuj@kruger.dk
Saturday, April 20, 1996
At 08:44 17-04-96 -0700, you wrote:
>
>VC4.0/Win '95
>
>I have derived a class from CListView and am attempting to receive=20
>notifications when the user changes the header control. Specifically, wh=
en=20
>the user resizes a column in the report view I'd like to take some actio=
n.
>
>I have searched MSDN etc. and discovered a message HDN_ITEMCHANGED but=20
>can't figure out how to intercept it or understand if that is the best=20
>mechanism in MFC.
As far as I can tell, it's HDN_ENDTRACK you'd like to intercept.
Unfortunately, you don't know the Id of the header control (and even if y=
ou
found out it was 1001, there's no guarantee it will stay so).
So you can't use ON_NOTIFY(HDN_ENDTRACK, someID, OnHdnEndTrack).
You can either use ON_NOTIFY_RANGE(HDN_ENDTRACK, 0, 0xFFFFFFFF, OnHdnEndT=
rack),
or you can override the OnChildNotify of your view.
Niels Ull Jacobsen, Kr=FCger A/S (nuj@kruger.dk)
Everything stated herein is THE OFFICIAL POLICY of the entire Kruger grou=
p
and should be taken as legally binding in every respect. Pigs will grow
wings and fly.
Mike Blaszczak -- mikeblas@msn.com
Wednesday, April 24, 1996
----------
From: owner-mfc-l@netcom.com on behalf of Niels Ull Jacobsen
Sent: Saturday, April 20, 1996 03:06
> As far as I can tell, it's HDN_ENDTRACK you'd like to intercept.
It's actually HDN_BEGINTRACK.
>Unfortunately, you don't know the Id of the header control (and even if you
> found out it was 1001, there's no guarantee it will stay so).
The ID is zero, and it will always be zero--if it is there.
.B ekiM
TCHAR sz[] = _T("Check twice and save a life; motorcycles are everywhere!");
| Вернуться в корень Архива
|