Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

How can I get each event in the EventHandlerList

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Georg Winkelhofer - 07 Oct 2004 09:13 GMT
Hi,

I'm using a listview control and want to track the mouse events in the
column header of the listview control. After inhereting the ColumnHeader i
can get the events in an EventHandlerList. But i don't know how to get each
EventHandler of the list.
I want to override the MouseMove event to disable the change of the mouse
cursor when the mouse moves over the divider of the column header.

How can i do this?

Thanx,
Georg
Stoitcho Goutsev \(100\) [C# MVP] - 07 Oct 2004 14:42 GMT
Hi Georg,

First of all ColumnHeader doesn't have MouseMove event. It does have Events
as long as it inherits this property from the Component class.

Secon of all even if it had that event you cannot get the event handlers.
Events property holds list of event handlers for each event; WindowsForms
uses that patter in order to oprimize the memory usage. However each event
is registered under some key, which you don't know thus, you cannot use that
list for anything, but your own events.
Anyways, If ColumnHeader had that event following the design pattern used
throughout WindowsForms there would be protected virtual OnMouseMove method,
which you'd be able to override, thus overriding the event handling.

Signature

HTH
Stoitcho Goutsev (100) [C# MVP]

> Hi,
>
[quoted text clipped - 10 lines]
> Thanx,
> Georg
Georg Winkelhofer - 07 Oct 2004 15:55 GMT
Hi Stoitcho,

Thank you for your informations. I didn't find any information about the
OnMouseMove methods, but i tried to override this method again. But i got a
compiler error: no suitable method found to override. Is there any other
possibility to get the mouse move event?

Thanx,

Georg

"Stoitcho Goutsev (100) [C# MVP]" wrote:

> Hi Georg,
>
[quoted text clipped - 9 lines]
> throughout WindowsForms there would be protected virtual OnMouseMove method,
> which you'd be able to override, thus overriding the event handling.
Stoitcho Goutsev \(100\) [C# MVP] - 08 Oct 2004 14:23 GMT
Hi Georg,

No, there is not because I said Column header doesn't have that event
(that's why it has no OmMouseMove method).
See ColumnHeader is a component, not a control. In most of the cases
controls provide those interactivity events. It is possible that components
may have them too but it is verry unlikely. In this particular case with
ColumnHeader it doesn't. Look at the control that uses those headers. there
you will find the event, I believe

Signature

HTH
Stoitcho Goutsev (100) [C# MVP]

> Hi Stoitcho,
>
[quoted text clipped - 27 lines]
>> method,
>> which you'd be able to override, thus overriding the event handling.
Georg Winkelhofer - 11 Oct 2004 16:29 GMT
Hi Stoitcho,

Thank you again for your explanations. Sorry for my misunderstandings of
components and controls.
Now i have to explain a little bit more of my project and what i've already
tested:
The width of the columns in the ListView is fixed and the user is not
allowed to resize the column width neither with a mouse drag nor with a
double click. I've got a tip from Claes Bergefall to catch these events.
But the mouse cursor changes to "ve_sizeb.cur". If you see this cursor you
think you can resize the column width.
Now i wanted to catch the mouse move event before the mouse cursor changes
to "ve_sizeb.cur". My first guess was to use the mouse move event of the
ListView. But there is no mouse move event when you move the mouse over the
column header.

Here is my MouseMove event:
protected override void OnMouseMove(MouseEventArgs e)
{
 // store the mouse position in the HitTestInfo structure
 HDHITTESTINFO mPoint = new HDHITTESTINFO();
 mPoint.pt.X = e.X;
 mPoint.pt.Y = e.Y;

 // get the position of the mouse in the listview header.
 // The header control includes all columns.
 // Get a handle to the header control.
 IntPtr hc;
 hc = SendMessage(this.Handle, new IntPtr(LVM_GETHEADER), new IntPtr(0),
new IntPtr(0));
 hc = SendMessage(hc, new IntPtr(HDM_HITTEST), new IntPtr(0), ref mPoint);
 if (mPoint.flags != HHT_ONDIVIDER)
   base.OnMouseMove (e);
}

There is never a flag with HHT_ONDIVIDER, all flags i get are HHT_BELOW.
There is no y-position of the mouse smaller than 18 (the height of the
ColumnHeader). Now i think there is a control catching the mouse move event
in the area of the column headers.
Is there any way to prevent the mouse cursor to change to the resizign cursor?

Thank you,
Georg

"Stoitcho Goutsev (100) [C# MVP]" wrote:

> Hi Georg,
>
[quoted text clipped - 5 lines]
> ColumnHeader it doesn't. Look at the control that uses those headers. there
> you will find the event, I believe
Stoitcho Goutsev \(100\) [C# MVP] - 14 Oct 2004 00:41 GMT
Hi Georg,

listview column header is a separate window. That's why you don't receive
messages (events) for it. Native ListView doesn't notify for mouse moves
over the header thus .NET cotntrol doesn't have events as well.
I can see that this window has CLASSWND of SysHeader32 so it can be
subclassed in order to intercept those messages, however this is not good
idea since it is not documented, thus subject to change. Beside this, IMHO,
there is no way to process those messages.

Signature

Stoitcho Goutsev (100) [C# MVP]

> Hi Stoitcho,
>
[quoted text clipped - 57 lines]
>> there
>> you will find the event, I believe
Georg Winkelhofer - 14 Oct 2004 13:39 GMT
Hi Stoitcho,

thank you again for your help. It's time for me to give up looking for a
solution to my problem. I've to live with the change of the mouse cursor, but
I#ve learned a lot new things about controls and components in .NET.

Thanx,

Georg

"Stoitcho Goutsev (100) [C# MVP]" wrote:

> Hi Georg,
>
[quoted text clipped - 5 lines]
> idea since it is not documented, thus subject to change. Beside this, IMHO,
> there is no way to process those messages.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.