15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


[Q] CListCtrl - HDN_ITEMCHANGED

Kevin Dahl -- kdahl@glenqcy.glenayre.com
Wednesday, December 04, 1996

Environment: VC++ 4.2-flat, Win95/NT 4.0

Hi,
I have a CListCtrl that I've extended into an owner drawn
list control.  I've overriden the OnNotify function so I could
trap on the HDN_ITEMCHANGED message that is generated
when a column width has changed.  

	Code sample #1 works on Win95 when built on Win95 and
	also works on NT when build for unicode on NT.  However
	it doesn't work on NT when the system is built for ANSI.  What
	I found was that on NT the message sent is 
HDN_ITEMCHANGEDW.

Code sample#2 works on both 95 and NT when built for ANSI
and only on NT when build for unicode, as expected.

I've also found this in the include\commctrl.h file 

#####################################################################3
#define HDN_ITEMCHANGINGA       (HDN_FIRST-0)
#define HDN_ITEMCHANGINGW       (HDN_FIRST-20)
#define HDN_ITEMCHANGEDA        (HDN_FIRST-1)
#define HDN_ITEMCHANGEDW        (HDN_FIRST-21)
#define HDN_ITEMCLICKA          (HDN_FIRST-2)
#define HDN_ITEMCLICKW          (HDN_FIRST-22)
#define HDN_ITEMDBLCLICKA       (HDN_FIRST-3)
#define HDN_ITEMDBLCLICKW       (HDN_FIRST-23)
#define HDN_DIVIDERDBLCLICKA    (HDN_FIRST-5)
#define HDN_DIVIDERDBLCLICKW    (HDN_FIRST-25)
#define HDN_BEGINTRACKA         (HDN_FIRST-6)
#define HDN_BEGINTRACKW         (HDN_FIRST-26)
#define HDN_ENDTRACKA           (HDN_FIRST-7)
#define HDN_ENDTRACKW           (HDN_FIRST-27)
#define HDN_TRACKA              (HDN_FIRST-8)
#define HDN_TRACKW              (HDN_FIRST-28)
#define HDN_GETDISPINFOA        (HDN_FIRST-9)
#define HDN_GETDISPINFOW        (HDN_FIRST-29)
#define HDN_BEGINDRAG           (HDN_FIRST-10)
#define HDN_ENDDRAG             (HDN_FIRST-11)

#ifdef UNICODE
#define HDN_ITEMCHANGING         HDN_ITEMCHANGINGW
#define HDN_ITEMCHANGED          HDN_ITEMCHANGEDW
#define HDN_ITEMCLICK            HDN_ITEMCLICKW
#define HDN_ITEMDBLCLICK         HDN_ITEMDBLCLICKW
#define HDN_DIVIDERDBLCLICK      HDN_DIVIDERDBLCLICKW
#define HDN_BEGINTRACK           HDN_BEGINTRACKW
#define HDN_ENDTRACK             HDN_ENDTRACKW
#define HDN_TRACK                HDN_TRACKW
#define HDN_GETDISPINFO          HDN_GETDISPINFOW
#else
#define HDN_ITEMCHANGING         HDN_ITEMCHANGINGA
#define HDN_ITEMCHANGED          HDN_ITEMCHANGEDA
#define HDN_ITEMCLICK            HDN_ITEMCLICKA
#define HDN_ITEMDBLCLICK         HDN_ITEMDBLCLICKA
#define HDN_DIVIDERDBLCLICK      HDN_DIVIDERDBLCLICKA
#define HDN_BEGINTRACK           HDN_BEGINTRACKA
#define HDN_ENDTRACK             HDN_ENDTRACKA
#define HDN_TRACK                HDN_TRACKA
#define HDN_GETDISPINFO          HDN_GETDISPINFOA
#endif
#####################################################################3


My question is: If I want to build one executable for both 95 and
NT (ANSI) do I have to check for both messages or does NT
provide some automatic conversion of the messages it sends
though the system?  Is there a better way to handle this?

TIA,

Kevin Dahl


#####################################################################3
## Code - 1 begins
BOOL UI_CListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
    HD_NOTIFY *pHD = (HD_NOTIFY*)lParam;

    if ( pHD->hdr.code == HDN_ITEMCHANGED ) 
        colWidth = pHD->pitem->cxy;

   *pResult = 0;
    return CListCtrl::OnNotify(wParam, lParam, pResult);
}
## Code - 1 ends 
#####################################################################3
## Code - 2 begins
BOOL UI_CListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
    HD_NOTIFY *pHD = (HD_NOTIFY*)lParam;

    if (  pHD->hdr.code == HDN_ITEMCHANGEDA || 
	    pHD->hdr.code == HDN_ITEMCHANGEDW ) 
        colWidth = pHD->pitem->cxy;

   *pResult = 0;
    return CListCtrl::OnNotify(wParam, lParam, pResult);
}
## Code - 2 ends 
#####################################################################3







P.J. Tezza -- pj@exemplarsoftware.com
Saturday, December 07, 1996

Kevin,

In general, Windws NT is supposed to remember from your class =
registration or other events if your application expects messages to be =
sent in ANSI or UNICODE. Based on your experiments, this sounds like =
either a bug or a flaw in the design of this control. I wonder if the =
same problem exists for other common control notifications.

PJ



Kostya Sebov -- sebov@is.kiev.ua
Tuesday, December 10, 1996

>   Environment: VC++ 4.2-flat, Win95/NT 4.0
>
>   Hi,
>   I have a CListCtrl that I've extended into an owner drawn
>   list control.  I've overriden the OnNotify function so I could
>   trap on the HDN_ITEMCHANGED message that is generated
>   when a column width has changed.
>
>       Code sample #1 works on Win95 when built on Win95 and
>       also works on NT when build for unicode on NT.  However
>       it doesn't work on NT when the system is built for ANSI.  What
>       I found was that on NT the message sent is
>   HDN_ITEMCHANGEDW.
>
>   Code sample#2 works on both 95 and NT when built for ANSI
>   and only on NT when build for unicode, as expected.
>
>   
>
>   My question is: If I want to build one executable for both 95 and
>   NT (ANSI) do I have to check for both messages or does NT
>   provide some automatic conversion of the messages it sends
>   though the system?  Is there a better way to handle this?
>
>   TIA,
>
>   Kevin Dahl
>

There must be a message or notification, which is sent asking what type of
notifivation (ANSI or UNICODE) you'd like to receive. You should provide
a handlet to this message in order not to depend on the default OS behaviour.

If cann't find it let me know and I'll direct you more precisely.

HTH



--- 
Kostya Sebov. 
----------------------------------------------------------------------------
Tel: (38 044) 266-6387 | Fax: (38 044) 266-6195 | E-mail: sebov@is.kiev.ua




| Вернуться в корень Архива |