On Wed, 24 Jun 2009 19:52:41 +0200, Christian Treffler
<CTreffler.NG.Dev0@xxxxxx> wrote:
Quote:
>Hi,
>
>I wrote some code to add images to button controls (.Net 2.0, Visual
>Studio 2005, C#). There are 4 images for 4 states: normal, mousebutton
>down, mousenter, disabled.
>
>So far everything works with only a small problem: If I click on the
>button and drag the mouse pointer from the control with mouse button
>still down, the MouseLeave event is not triggered. The button outline
>goes back to the normal state, but the image changes back to normal only
>after I release the mousebutton.
>I can't fins an event which catches 'Leave control with mouse button
>still down'.
>
>Here's a piece of my code:
>
>public static void AddHandler(Button btn)
> { \\ Assign the methods to the events
> btn.MouseDown += new System.Windows.Forms.MouseEventHandler(BtnDown);
> btn.MouseUp += new System.Windows.Forms.MouseEventHandler(BtnUp);
> btn.MouseEnter += new System.EventHandler(BtnEnter);
> btn.MouseLeave += new System.EventHandler(BtnLeave);
> }
>
>public static void BtnDown(object sender, EventArgs e)
> {
> Button btn = (Button)sender;
> btn.ImageIndex = 1; // The button ImageList property
> // contains an imagelist with the 4 images
> }
>
>public static void BtnUp(object sender, EventArgs e)
> {
> Button btn = (Button)sender;
> btn.ImageIndex = 0;
> }
>
>public static void BtnEnter(object sender, EventArgs e)
> {
> Button btn = (Button)sender;
> btn.ImageIndex = 2;
> }
>
>public static void BtnLeave(object sender, EventArgs e)
> {
> Button btn = (Button)sender;
> btn.ImageIndex = 0;
> }
>
>
>CU,
>Christian
I think the best you can do is to check in MouseMove if the mouse
cursor is over the button or not.