Board index » delphi » Strange behaviour with TTabControl and TTabSheet ?

Strange behaviour with TTabControl and TTabSheet ?

Hi,

Is there something I have missed or is there a strange behaviour with
TTabControl and TTabSheet in Delphi 5?

To clearify what I mean, I have a TTabControl on a form with several
TTabSheets. The strange behaviour I seem to get is with the OnEnter event. I
should think that, whenever you change to a new TabSheet in the TabControl,
the TabSheet's OnEnter event would get fired. Am I right? Somehow this event
only gets fired if I actively choose some component, like an edit component,
on the TabSheet. Nothing happens if I don't choose a component. Now, this
doesn't seem logical as the way I see it, when I change the tab, I enter the
TabSheet belonging to the tab. Or is there something I have missed here?

I need to do different actions for different TabSheets when I enter them,
that is when I change the Tab and the TabControl. I might be able to use the
OnChanged event, but it seems more logical to use the OnEnter.

S?ren Tauber Lassen
http://www.bosoft.dk

 

Re:Strange behaviour with TTabControl and TTabSheet ?


Quote
S?ren Tauber Lassen wrote in message <805cps$hg...@forums.borland.com>...

>To clearify what I mean, I have a TTabControl on a form with several
>TTabSheets. The strange behaviour I seem to get is with the OnEnter event.
I
>should think that, whenever you change to a new TabSheet in the TabControl,
>the TabSheet's OnEnter event would get fired. Am I right? Somehow this
event
>only gets fired if I actively choose some component, like an edit
component,
>on the TabSheet. Nothing happens if I don't choose a component. Now, this
>doesn't seem logical as the way I see it, when I change the tab, I enter
the
>TabSheet belonging to the tab. Or is there something I have missed here?

The fact that a TabSheet becomes visible doesn't mean it has been "entered".
OnEnter fires only when a control actually gets the focus. In fact the
TabControl still has the focus after clicking on a tab. Try using the
TabSheet's OnShow event instead.

--
Wayne Niddery - WinWright Consulting
I'm a Daddy! Curtis Tomoki Niddery, born Oct 29, 1999
RADBooks - http://members.home.net/wniddery/

Re:Strange behaviour with TTabControl and TTabSheet ?


Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message

Quote
> The fact that a TabSheet becomes visible doesn't mean it has been
"entered".
> OnEnter fires only when a control actually gets the focus. In fact the
> TabControl still has the focus after clicking on a tab. Try using the
> TabSheet's OnShow event instead.

I thought about using the onShow event, but I guess I was too tired and too
irritated at the time. But I solved the problem by using the OnChanged
event. I do believe, though, that the OnShow is better to solve my problem.

The thing that I just don't get is it worked with the OnEnter event in
Delphi 4, but went completly bannanas in D5. Was there an error in D4 making
the OnEnter event showhow behave like the OnShow event? What I did was take
a rather large project from D4 and compile it with D5 and that was when the
strange things started.

S?ren Tauber Lassen
www.bosoft.dk

Other Threads