PC Review


Reply
Thread Tools Rate Thread

Calculator like mouse events

 
 
Raj Chudasama
Guest
Posts: n/a
 
      22nd Sep 2005
I have a controls similiar to the windows calculator. (Please press some
buttons on your calculator to see what i am talking about)

So when u hover over a button it will change the state (it changes to
different image)
if u click it will show pressed image etc

now the problem:

the calculator does the following

when a button is clicked via mouse a pressed image is shown and when the
mouse is up it will show up state however if the mouse is still over the
button after clicking the button it will go to the hover state.

i am currently unable to do this. My control will show hover state, if you
press it will show pressed state and then the up state. however even if you
have your mouse still over the button after clicking the button it will not
show the hover state.



I am sure i have to "consume" an event or something but i don t know how and
which.

please help




 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      22nd Sep 2005
"Raj Chudasama" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> the calculator does the following
>
> when a button is clicked via mouse a pressed image is shown and when the
> mouse is up it will show up state


With you so far...

> however if the mouse is still over the button after clicking the button it
> will go to the hover state.


Doesn't do that for me - there doesn't appear to be a "hover state" of any
kind...


 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      22nd Sep 2005
Hi,

The same here, it does not has a hover state

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Mark Rae" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Raj Chudasama" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
>> the calculator does the following
>>
>> when a button is clicked via mouse a pressed image is shown and when the
>> mouse is up it will show up state

>
> With you so far...
>
>> however if the mouse is still over the button after clicking the button
>> it will go to the hover state.

>
> Doesn't do that for me - there doesn't appear to be a "hover state" of any
> kind...
>



 
Reply With Quote
 
Raj Chudasama
Guest
Posts: n/a
 
      22nd Sep 2005
Well i guess it will depend on what win version you are using, i am on XP
and it does the hover states. However mine are custom buttons that are
dropped on a picturebox and events tied to them.

Nonetheless, i got it figured out

what i did is the following:

i added code to the mouseup event... so when mouse is up it will check to
see if the mouse is till on the button it clicked on. if so then i just
call the mouse hover code on that button

private void picDialStar_MouseUp(object sender, MouseEventArgs e)

{


PictureBox p = (PictureBox)sender; //get current button that was clicked

System.Diagnostics.Debug.WriteLine("Picture box location"+
p.Location.ToString());

Rectangle r = new Rectangle(p.Location,p.Size); //picturbox rectangle

System.Diagnostics.Debug.WriteLine("Cursor location"+
Cursor.Position.ToString());


Point pt = this.PointToClient(Cursor.Position); //cursor position

System.Diagnostics.Debug.WriteLine("this.Parent.PointToClient"+
pt.ToString());


if(r.Contains(pt)) //if the rectangle contains the cursor then we should
show the hover state

{

picDialStar_MouseHover(sender,e);

return;

}

else //mouse is not over the image that was clicked so just show the up
state.

{

:

:

:

}


 
Reply With Quote
 
Chris Dunaway
Guest
Posts: n/a
 
      22nd Sep 2005
Raj Chudasama wrote:
> Well i guess it will depend on what win version you are using, i am on XP
> and it does the hover states. However mine are custom buttons that are
> dropped on a picturebox and events tied to them.
>
> Nonetheless, i got it figured out
>


All you need to do is handle MouseEnter and MouseLeave for the buttons.
In the MouseEnter, set a boolean or something to indicate that the
hover graphic should be used and in the mouseLeave, it indicates the
normal unclicked graphic.

Then, in the MouseUp, you display the correct one.

Private bUseHoverGraphic As Boolean

Public Sub MouseEnter(...)
bUseHoverGraphic = True
End Sub

Public Sub MouseLeave(...)
bUserHoverGraphic = False
End Sub

Public Sub MouseUp(...)
If bUserHoverGraphic Then
'Paint button with hover graphic
Else
'Paint button with normal graphic
End If
End Sub

 
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
webbrowser control: how to capture event of mouse hovering over thelink or mouse click events in webbrowser only? P-GPS Microsoft VB .NET 1 15th Dec 2007 11:31 AM
Capturing mouse events (Mouse up and down on the desktop) Ahmed Microsoft VB .NET 6 8th Jun 2006 06:52 AM
Capturing mouse events (Mouse up and down on the desktop) Ahmed Microsoft Dot NET Framework Forms 0 6th Jun 2006 06:54 PM
mouse events when the mouse is on a "child control" red Microsoft Dot NET 3 29th Jul 2005 07:49 AM
Calculator events Haim Turjeman Microsoft Dot NET 1 6th Aug 2003 04:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 PM.