PC Review


Reply
Thread Tools Rate Thread

Detect mouse leaving from a list view item

 
 
Mohit
Guest
Posts: n/a
 
      8th Oct 2008
Hi all,
I am working on a windows application with a list view on a form.
Now I wanted to show hand cursor when mouse is over list view item and
default(arrow) cursor at other places.

List view's ItemMouseHover event can tell me that mouse is on the
item and here I can change my cursor to hand. But I have no clue to
change it back to default cursor when mouse is moved out of the list
view item.

How can I detect that mouse is moved away/out of the list view
item??

I have also tried to use HitTest method of the list view in the
MouseMove event but it is causing lots of overhead and sometimes hangs
the application. So I am not using this option.
Can someone give me an idea how to achieve it.

Thanks!!
 
Reply With Quote
 
 
 
 
Ciaran O''Donnell
Guest
Posts: n/a
 
      8th Oct 2008
This seems to work fine for me. Never locks up. I dont know if you had an
issue with constantly setting the cursor. Thats why i check it before setting
it:

private void listView1_MouseMove(object sender, MouseEventArgs e)
{
if (listView1.HitTest(e.X, e.Y).Item == null && (this.Cursor !=
Cursors.Default))
{
this.Cursor = Cursors.Default;
}
else if (this.Cursor == Cursors.Default)
{
this.Cursor = Cursors.Hand;
}
}

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com


"Mohit" wrote:

> Hi all,
> I am working on a windows application with a list view on a form.
> Now I wanted to show hand cursor when mouse is over list view item and
> default(arrow) cursor at other places.
>
> List view's ItemMouseHover event can tell me that mouse is on the
> item and here I can change my cursor to hand. But I have no clue to
> change it back to default cursor when mouse is moved out of the list
> view item.
>
> How can I detect that mouse is moved away/out of the list view
> item??
>
> I have also tried to use HitTest method of the list view in the
> MouseMove event but it is causing lots of overhead and sometimes hangs
> the application. So I am not using this option.
> Can someone give me an idea how to achieve it.
>
> Thanks!!
>

 
Reply With Quote
 
Mohit
Guest
Posts: n/a
 
      10th Oct 2008
Hi,
Thanks Ciaran for your response.

Even after adding up cursor check it is still causing up to lots of
overhead and hanging up the application. CPU utilization clock is
showing up 100% usage when mouse is moved over the list view and
various items for a considerable amount of time.

Is there some other alternative exist??
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListView: how to detect if the item is selected with the first mouse click? Jack Windows XP General 1 20th Jul 2008 06:43 PM
sub item in list view item invalid bounds during DrawItem in owner draw Smokey Grindle Microsoft VB .NET 0 2nd Aug 2006 05:24 PM
Dropdown: easy way to detect if item is in the list? A C Microsoft Access Forms 1 17th Nov 2005 10:26 PM
CWnd and CStatic Based Windows, How to detect mouse leaving the w =?Utf-8?B?RWl0YW4=?= Microsoft VC .NET 2 28th Apr 2005 09:46 AM
CWnd & CStatic Based Windows, How to detect mouse leaving the win =?Utf-8?B?RWl0YW4=?= Microsoft VC .NET 0 28th Apr 2005 07:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:37 AM.