Board index » cppbuilder » Re: enhance my app

Re: enhance my app


2005-02-02 06:13:30 PM
cppbuilder75
"JD" < XXXX@XXXXX.COM >wrote in message
Quote

"Simon D" < XXXX@XXXXX.COM >wrote:
>
>Your comment explains exactly why I would use it. Belt and braces...

That makes no sense. The *only* benifit would be during
developement and all it would do is replace one type of error
with an other.
It would help prevent errors and speed up their location.
Quote
The difference being extra overhead in the
final product that has no purpose. It's just extra overhead
that needs to be removed.

~ JD
Accidents happen. The cost in overhead is a minor concern IMHO.
Try this with a TListBox and a TButton's events also connected.
// -------------
void __fastcall TForm1::EditEnter(TObject *Sender)
{
TEdit* p = static_cast<TEdit*>(Sender);
p->Color = clYellow;
p->Text = "Test"; // *???*
}
// -------------
void __fastcall TForm1::EditExit(TObject *Sender)
{
TEdit* p = static_cast<TEdit*>(Sender);
p->Color = clWhite;
}
// ------------
It compiles and runs, and does not throw any exceptions, so what is
happening on the 'test' line for the other controls?
neither
ListBox1->Text = "Test";
nor
Button1->Text = "Text";
compiles.
With the colour changes the mistake may be obvious, but in other cases it
may not. Accidentally connect up a TImage's event, and you get AV's, which
you need to discover while testing.
When I do share event handlers, it is often with different control types, so
using dynamic_cast has become a habit for me anyway (right or wrong).
Simon.
 
 

Re:Re: enhance my app

JD wrote:
Quote
"Ron Eggler @ Work" < XXXX@XXXXX.COM >wrote:
>

Please trim your posts. Help keep the server less cluttered.

>[...] But i want to color it back to clWindow after the Exit-
>Function was executed and not just, when annother Edit was
>selected.

That is exactly what the code I posted does. Did you assign the
events to all of the TEdits?
that's correct, but u forgot that i already have alot of code in my OnExit
functions from the TEdits. that's why i can't do just one OnExit-function.
Quote

~ JD