Board index » delphi » Bug in TStatusBar?

Bug in TStatusBar?


2004-02-08 09:57:43 AM
delphi137
I've been working on doing some enhancement/cleanup on a C++ Builder
project (BCB 5 Professional). In the last couple of days, I ran into an
interesting bug, but found no trace of it in Quality Central, so thought
I would ask here.
BTW, QC appears to be affected by the recent Microsoft Internet Explorer
update, in that it won't even let me enter my username/password to get
in to QC. I have posted this in the QC newsgroup, so hopefully it will
get corrected.
Here's the bug: I was getting an AV during a hint function, because the
SimplePanel property of a StatusBar had inadvertantly been set to
'false', even though there were no members of the Panels property of the
StatusBar.
It is my belief that one should not be able to set the SimplePanel
property to 'false' unless at least one member of 'Panels' exists,
because without any members of Panels, all of the example code for doing
hints is moot.
In regards to the argument that one could programmatically change the
Panels property, I'd state that one could change the SimplePanels
property after doing so.
Questions:
1) Has anyone run into this before?
2) I am assuming that this bug exists in Delphi 5, since I am using BCB5.
Can someone confirm this? Does it still exist in Delphi 6, 7, or 8?
3) I was unable to find any entries in QC for TStatusBar. Has someone
found/reported this before, and if so, under what entry?
Thanks for any response.
David Erbas-White
 
 

Re:Bug in TStatusBar?

David Erbas-White writes:
Quote
Here's the bug: I was getting an AV during a hint function,
because the SimplePanel property of a StatusBar had inadvertantly
been set to 'false', even though there were no members of the
Panels property of the StatusBar.

It is my belief that one should not be able to set the
SimplePanel property to 'false' unless at least one member of
'Panels' exists, because without any members of Panels, all of
the example code for doing hints is moot.

In regards to the argument that one could programmatically change
the Panels property, I'd state that one could change the
SimplePanels property after doing so.

Questions:

1) Has anyone run into this before?
2) I am assuming that this bug exists in Delphi 5, since I am using
BCB5. Can someone confirm this? Does it still exist in Delphi 6,
7, or 8? 3) I was unable to find any entries in QC for
TStatusBar. Has someone found/reported this before, and if so,
under what entry?
I actually fired up Delphi 7 to see what happens with my hint function
that pops it on the Status Bar. However, I am not sure how to
intelligently respond, because "a hint function" seems pretty vague.
Application.OnHint := ShowHint; // Sends hint text to status bar
procedure TfrmMain.ShowHint(Sender: TObject);
begin
StatusBar1.Panels[1].Text := Application.Hint;
LogText(Application.Hint);
end;
Granted, this could be cleaned up a bit, but it works. Now,
changing to:
StatusBar1.SimpleText := Application.Hint
makes the hints appear in both Panels[0] and Panels[1] at run time.
Dropping a second TStatusBar on my form, then adding the line
StatusBar2.SimpleText := Application.Hint;
verifying the OI showed SimplePanel = false, and Panels was empty,
then running the app worked as expected - hints in all StatusBar
panels.
1) No
2) I can not confirm it, but I don't think I am running a similar set
of code
3) N/A yet
As it happens, I disagree with your proposal, but more because it
would likely break legacy applications.
Finally, obligatory note - this probably belongs in
.vcl.components-using or something. But I don't hang out there, so
I won't set follow-up.
-Brion
 

Re:Bug in TStatusBar?

"Brion L. Webster" <XXXX@XXXXX.COM>writes
Quote

I actually fired up Delphi 7 to see what happens with my hint function
that pops it on the Status Bar. However, I am not sure how to
intelligently respond, because "a hint function" seems pretty vague.

I thought David was referring to the AutoHint property of the StatusBar - it
automatically writes any hints into the status bar for you. I did a quick
test with Delphi 7 with SimplePanel set false and it didn't AV.
Chris Burrows
CFB Software
www.cfbsoftware.com
 

Re:Bug in TStatusBar?

Chris Burrows writes:
Quote
"Brion L. Webster" <XXXX@XXXXX.COM>writes
news:4027c0bd$XXXX@XXXXX.COM...

>I actually fired up Delphi 7 to see what happens with my hint function
>that pops it on the Status Bar. However, I am not sure how to
>intelligently respond, because "a hint function" seems pretty vague.
>


I thought David was referring to the AutoHint property of the StatusBar - it
automatically writes any hints into the status bar for you. I did a quick
test with Delphi 7 with SimplePanel set false and it didn't AV.

Chris Burrows
CFB Software
www.cfbsoftware.com




No, actually, at this point, I feel like an absolute moron.
I've been using both BCB and Delphi since they came out, and NEVER
NOTICED the AutoHint property. I am busy kicking myself.
On the other hand, I just went back into the BCB 5 help system to see
what happens when I look up help for 'hint'. No mention, anywhere, of
AutoHint. Just the 'standard' examples of how to implement a hint
event, how to assign it, how to get the long hint, etc. So, that is what
I've done all these years. Don't know if the AutoHint property has been
there since the beginning or not, but it is somewhat problematic that it
isn't even mentioned in any of the help relating to 'hint'.
But, I do have one form that has special processing for hints, so my
basic 'assertion' still remains.
BTW, I checked, and in Delphi 5, the DEFAULT behavior for a TStatusBar
when placed on a form is that SimplePanel is set to false, but no Panels
are present. Again, my assertion is that this is an illegal state for
(what one would expect) from the description of the TStatusBar, and you
shouldn't be able to have SimplePanel set false if no Panels are present.
What makes it more interesting is to look at how the VCL actually
handles this (for the AutoHint, for example). If you have SimplePanel
set false, but no Panels present, IT ACTS AS THOUGH SIMPLEPANEL WERE SET
TO TRUE!!!
This is not obvious, nor is it documented (AFAIK).
So, at this point, my assertion is that not only is there a bug (in the
sense of the StatusBar being able to go to an illegal state), but that
the operation of certain functions ignore the state of SimplePanel,
unbeknownst to the developer. Added to this is the 'brevity' (for lack
of a better word) of the documentation regarding hints, and this becomes
a bit more problematic.
BTW, while I am not necessarily against the way that the VCL is handling
this case, it brings up two issues to mind: 1) the lack of documentation
on how this is handled, and 2) the fact that a situation is 'handled'
that leads the developer blissfully down a path to destruction, if he in
fact was assuming the presence of a panel, and sees that the hint
function is working. The fact that SimplePanel is ignored for this
could well lead a developer to not be aware that SimplePanel is set to
the incorrect state (as happened in my case). In this instance, the VCL
is 'protecting' the developer from an error, but the documentation gives
no clue that this is even a possibility.
Thanks for the comments, everyone. While I still feel that there is a
bug in TStatusBar, it is offset by the {*word*164} I am feeling over
AutoHint... <G>
David Erbas-White
 

Re:Bug in TStatusBar?

David Erbas-White writes:
Quote
No, actually, at this point, I feel like an absolute moron.

I've been using both BCB and Delphi since they came out, and
NEVER NOTICED the AutoHint property. I am busy kicking myself.
Um, AutoWhat? Looks like I could use a little kicking myself.
-Brion
 

Re:Bug in TStatusBar?

"Brion L. Webster" <XXXX@XXXXX.COM>writes
Quote
David Erbas-White writes:

>No, actually, at this point, I feel like an absolute moron.
>
>I've been using both BCB and Delphi since they came out, and
>NEVER NOTICED the AutoHint property. I am busy kicking myself.

Um, AutoWhat? Looks like I could use a little kicking myself.

Further investigation indicates AutoHint was introduced in D4. Don't feel
too bad - I didn't find it (accidentally) until Delphi 7 either.
Chris Burrows
CFB Software
www.cfbsoftware.com