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

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


CListCtrl Header Messages ?

Danny Lauwers -- dlauwers@innet.be
Saturday, April 20, 1996

Hello,

I would like to disable the ability to resize the columns in my ClistCtrl
derived class, I have not found any parameter to tell this to the control
itself ?? I have tried to intercept the message from the CListCtrl via the
OnNotify. I found a HDN_BEGINTRACK notify message but I do not understand
how it is used in MFC ??

Any clues anybody ??

I am using NT351 and VC++4.0 and MFC4.0.

Thanks 
Danny Lauwers

==========================================================
Ing. Danny Lauwers (dlauwers@innet.be)
Intersoft Electronics
Lammerdries 27
2250 Olen Belgium Europe
Tel: +32 14 231811
Fax: +32 14 231944
----------------------------------------------------------
 Radar verification Hard- & software
 Fotofinish and timing of sportevents
 Footscan applications
 and more ...
==========================================================




Tommy Hui -- thui@slip.net
Tuesday, April 23, 1996

[Mini-digest: 4 responses]

Hi Danny,

If you take a look at the online help for HDN_BEGINTRACK, you'll see that
you can return FALSE to allow tracking of the columns or return TRUE to
prevent tracking. Now the only problem is which window actually gets the
HDN_BEGINTRACK message. I would assume the CListCtrl itself does which means
you'll have to catch the notification message at the CListCtrl level (i.e.
derive a class from CListCtrl, put in the necessary handlers in that class
and use the derived class in your code, rather than CListCtrl).

Tommy

-----From: mikeblas@interserv.com

On Sat, 20 Apr 1996, Danny Lauwers  wrote:

>I would like to disable the ability to resize the columns in my ClistCtrl
>derived class, I have not found any parameter to tell this to the control
>itself ??

There's currently no style you can set that will make the header positions 
stick.

>I have tried to intercept the message from the CListCtrl via the
>OnNotify. I found a HDN_BEGINTRACK notify message but I do not understand
>how it is used in MFC ??

What, specifically, dont' you understand?  You should handle this message in 
your CListCtrl-derived class and return TRUE to make Windows not allow the 
user to start changing the width of the list column.

>I am using NT351 and VC++4.0 and MFC4.0.

Thanks.

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");

-----From: David.Lowndes@bj.co.uk

Danny,

I wanted to do this the other day (under Win95) & found using Spy++ that the
HDN_BEGINTRACK notification isn't sent to the parent of the list control (usually
the dialog). This notification is only sent from the header control to its immediate
parent (the list control).

Dave Lowndes
-----From: Anil Kumar K 

Hi,
	To prevent the resizing of the columns, handle the 
ON_NOTIFY message in the listctrl derived class since listcontrol is the parent of the header control. 

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

	if ( ((NMHDR*)lParam)->code == HDN_BEGINTRACK)
		bRetVal = FALSE;
		
	*pResult = 0;
	return bRetVal;
}

Hope this helps.

Anil Kumar .K




Graham -- Cunningham@tgd.swissptt.ch
Friday, April 26, 1996


Well I am probably being stupid but I cant get this to work.
Env vc4.0 winNT3.51

I have put an OnNotify function into my CListCtrl deived class and tested=
 for HDN_BEGINTRACK, HDN_ENDTRACK and HDN:TRACK=20
	switch (code)
	{
	case HDN_ENDTRACK:
	case HDN_TRACK:
	case HDN_BEGINTRACK:
		//any code
		break;
	default:
		break;
	}
I then set a breakpoint in the case statement and it never goes in there.=
 I then thought about using message reflection but this seems to be desig=
ned for OLE controls and not a derived class whatever I couldnt get this =
working either.

My work around at the moment is to work out the size of the column in Dra=
wItem and then draw the text this seems to work OK. I would still really =
like to know why my OnNotify doesnt work though.



Graham Cunningham=20
email         : Cunningham@tgd.swissptt.ch
phone       : 00 41 31 338 0633



Gonzalo Isaza -- gonzaloi@microsoft.com
Monday, April 29, 1996

[Mini-digest: 3 responses]

The problem resides in the fact that Windows NT is creating a UNICODE
header control even though you have compiled as non-unicode build.  You
can verify it with spy++.  The way to work- around it would be

case HDN_ENDTRACKA:
case HDN_ENDTRACKW:

Keep in mind that because of this bug any notification involving strings
will receive -- most likely :) -- UNICODE strings (wide characters). 
This information is important if you are handling the strings in
HD_ITEM.

You can definitely use reflection on controls that are not OLE.  You can
use  ON_NOTIFY_REFLECT or ON_NOTIFY_REFLECT_EX.   In this specific case,
you would not want to reflect the message back to the header control but
handling it on the listctrl itself.

Gonzalo Isaza
I speak for myself. I do not speak for Microsoft.  

-----From: dal.ghotra@rebis.com


     I assume that code execution occurs upto and inside your virtual 
     OnNotify() function but not into your switch statement.
     In my code I am testing for the UNICODE defines.
     I.e. HDN_ENDTRACKW (instead of HDN_ENDTRACK)
          HDN_BEGINTRACKW (instead of HDN_BEGINTRACK)
        etc.....

dal.ghotra@rebis.com

-----From: Gonzalo Isaza 

Further information on this topic.  The behavior is not actually a bug. 
>It's by design.  Let the listview forward the messages on to parent. 
When the messages are forwarded, they will be ANSI.  You can also handle
the reflected message in the listview and it should be ANSI at that
>point.
>
>All the common controls are Unicode internally, so the listview will
>naturally expect unicode notifications from its child header control
>window.





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