PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Problem with TabAlignment and button mouse enter/leave events

Reply

Problem with TabAlignment and button mouse enter/leave events

 
Thread Tools Rate Thread
Old 02-06-2005, 05:15 PM   #1
=?Utf-8?B?RmxhY2s=?=
Guest
 
Posts: n/a
Default Problem with TabAlignment and button mouse enter/leave events


Hello,

I encountered a strange problem and I do not know what is causing it.

I created an empty form, added a tabs control to it and set the tab control
dock style to fill. Then I added three tabpages to it. To the first tab page
I added three buttons. The first button's click handler would set the tab
control's tab alignment to TabAlignment.Left and the second buttons click
handler would set it to Bottom.

I added mouse enter and mouse leave handlers to the third button. Whenever
the mouse would enter the button, I would change its background color to
yellow. When the mouse leaves the button, I would set the color back to its
original state.

Now, when I start the form, the mouse enter/leave events work great and
everything is fine. However, once I change the tabs alignment by hitting one
of the first two buttons, the third button no longer fires it's mouse leave
event and only fires the mouse enter event once. The mouse enters and mouse
enter fires correctly, but it seems that the mouse leave event has been
unregistered when the tab control's tab alignment changed.

Does anyone know what can be causing this behavior?

Thanks,
-Flack
  Reply With Quote
Old 02-06-2005, 05:42 PM   #2
Mick Doherty
Guest
 
Posts: n/a
Default Re: Problem with TabAlignment and button mouse enter/leave events

It's a problem with any standard .net control and happens when the controls
Container is assigned a new handle.
Changing the TabAlignment cuases the TabControl to be destroyed and
recreated, resulting in a new handle.

You'll probably be better off coding in the MouseMove method of the button
and it's container.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


"Flack" <Flack@discussions.microsoft.com> wrote in message
news:4F8B06F6-424D-48D8-81A3-6AD2214566AD@microsoft.com...
> Hello,
>
> I encountered a strange problem and I do not know what is causing it.
>
> I created an empty form, added a tabs control to it and set the tab
> control
> dock style to fill. Then I added three tabpages to it. To the first tab
> page
> I added three buttons. The first button's click handler would set the tab
> control's tab alignment to TabAlignment.Left and the second buttons click
> handler would set it to Bottom.
>
> I added mouse enter and mouse leave handlers to the third button. Whenever
> the mouse would enter the button, I would change its background color to
> yellow. When the mouse leaves the button, I would set the color back to
> its
> original state.
>
> Now, when I start the form, the mouse enter/leave events work great and
> everything is fine. However, once I change the tabs alignment by hitting
> one
> of the first two buttons, the third button no longer fires it's mouse
> leave
> event and only fires the mouse enter event once. The mouse enters and
> mouse
> enter fires correctly, but it seems that the mouse leave event has been
> unregistered when the tab control's tab alignment changed.
>
> Does anyone know what can be causing this behavior?
>
> Thanks,
> -Flack



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off