Board index » cppbuilder » Problem changing Caption form property

Problem changing Caption form property


2004-02-12 05:59:56 PM
cppbuilder27
Hi & Thanks
I'm working with BCB 6 ENT on Win2000
When I try to change the main form Caption from
within the main form code, this way :
...
Caption = "New Caption";
...
The program compiles and runs but I get an
exception thrown at the above line execution point
at runtime :
Execption ... Invalid window handler ...
Where could the problem stand ?
Bye,
Dave Potz
 
 

Re:Problem changing Caption form property

"Dave" < XXXX@XXXXX.COM >wrote:
Quote
[...]
...

Caption = "New Caption";

...

The program compiles and runs but I get an exception thrown
at the above line execution point at runtime :

Execption ... Invalid window handler ...
Please provide the exact error message.
Quote
Where could the problem stand ?
Where exactly in your code is this line?
~ JD
 

Re:Problem changing Caption form property

"JD" < XXXX@XXXXX.COM >wrote :
Quote
Where exactly in your code is this line?

~ JD

It's inside an OnDisconnect Event Handler for a TClientSocket
object I've put on the main form itself. Note that all other update
( of the same form's buttons, labels and so on... are correctly
executed from inside the same Event Handler code ).
The form is correctly initialized before I call the Caption update
code line.
Dave
 

{smallsort}

Re:Problem changing Caption form property

"Dave" < XXXX@XXXXX.COM >wrote in message
Quote
It's inside an OnDisconnect Event Handler for
a TClientSocket object I've put on the main form itself.
Again, please show your actual code.
Gambit
 

Re:Problem changing Caption form property

Gambit wrote :
Quote
Again, please show your actual code
Thanks Gambit,
I've discovered the problem isn't in the Caption update code.
In fact, the exception is thrown on Application->Terminate
code, while closing my application.
Since the IDE de{*word*81} isn't able to trace the exact code
line that raises the error I supposed the problem could have
been somewhere in the native delphi code for a component
on the main form.
My supposition revealed ( I think) to be true, since this bug
started as I introduced in my Main Form a TPageControl
object instead of using multiple forms.
After over 50/60 experiments starting and stopping my app,
I noticed that, if I close the application without having explicitly
selected at list once each page of the control ( 4 in my case )
I get this {*word*193} critical error at application termination point.
If instead I select each page once by clicking on his title and
then exit my application, I get no error and everything closes
gracefully ( I'm sure it isn't a coincidence as I've triyed many
and many times getting the same result ).
Thanks,
Dave Potz
 

Re:Problem changing Caption form property

"Dave Potz" < XXXX@XXXXX.COM >wrote:
Quote
the exception is thrown on Application->Terminate code,
Terminate should be reserved for shutting down your
application when you encounter a critical error. If you call
the Main form's Close method instead, it will allow your
application to exit gracefully.
Quote
[...] started as I introduced in my Main Form a TPageControl
object instead of using multiple forms.
This is a tried and true alternative. If you want to resolve
your problems, you need to post some code.
~ JD
 

Re:Problem changing Caption form property

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
Terminate should be reserved for shutting down
your application when you encounter a critical error.
Not true. TApplication::Terminate() can be used for any reason.
Quote
If you call the Main form's Close method instead, it
will allow your application to exit gracefully.
So will TApplication::Terminate(). All Terminate() does is posts a WM_QUIT
to the message queue to make it stop, that's all. Once the queue is exited,
the VCL performs normal cleanup operations. In fact, TForm::Close() simply
calls TApplication::Terminate() anyway if it is the main form that is being
closed.
Gambit
 

Re:Problem changing Caption form property

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote
[...] In fact, TForm::Close() simply calls TApplication::Terminate()
I did not know that - obviousely.
~ JD
 

Re:Problem changing Caption form property

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
I did not know that - obviousely.
procedure TCustomForm.Close;
var
CloseAction: TCloseAction;
begin
//...
if CloseAction <>caNone then
if Application.MainForm = Self then Application.Terminate
//...
end;
Gambit