This issue may trace back to MS Windows API: memory must be allocated for the 
title. If you set the title at design time, Delphi is usually intelligent 
enough to pre-allocate the memory. At run time, setting it equal to a string 
value will crash an app, because strings are lifetime-managed: once it goes out 
of scope (e.g. at the end of a procedure), the title points to an invalid 
location.

Work-arounds: global strings that last the lifetime of the app; allocate memory 
for a buffer; allocate an array of char...

Bart

----- Original Message ----
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, August 1, 2007 8:00:01 AM
Subject: Delphi Digest, Vol 55, Issue 1

Send Delphi mailing list submissions to
    [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
    http://www.elists.org/mailman/listinfo/delphi
or, via email, send a message with subject or body 'help' to
    [EMAIL PROTECTED]

You can reach the person managing the list at
    [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Delphi digest..."


Today's Topics:

   1. Re: Delphi IDE crashes when I try to use Application.Title
      (CubicDesign)


----------------------------------------------------------------------

Message: 1
Date: Tue, 31 Jul 2007 14:14:30 +0200
From: CubicDesign <[EMAIL PROTECTED]>
Subject: Re: Delphi IDE crashes when I try to use Application.Title
To: Borland's Delphi Discussion List <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Wow!
I didn't know about that. Of course there is nothing about that in 
Borland's help file.

Anyway that IDE crash gave me the lesson so I left the 
'Application.Title' unchanged and I use a different approach now.
Also, I will try to move my code out from DPR as you suggested. I need 
to insert code before 'create forms' and after 'create forms'. It was 
much easier to read the code while it was all there.

Thank you very much Rob.

 



Rob Kennedy wrote:
> CubicDesign wrote:
>   
>> *begin
>>   Application.Initialize;
>>   Application.Title := 'Crash me';
>>   ...
>>   if NOT TrialAlreadyAnouncedToday (Application.Title) 
>> then...                     < guilty
>>   Application.Run;
>> end.*
>>  
>>
>>
>>
>> If I change the line
>>   if NOT TrialAlreadyAnouncedToday (Application.Title) then...
>> in
>>   if NOT TrialAlreadyAnouncedToday ('Application.Title') then...
>> it works.
>>     
>
> The expression "Application.Title" must not appear more than once in the 
> DPR file, and when it appears, it must be on the left in an assignment 
> statement. That expression is special since the IDE needs it for 
> populating the project-options dialog, as well as for getting its 
> bearings on the compiler-generated code.
>
> I've solved it like this:
>
> var
>    App: TApplication;
> begin
>    App := Application;
>    App.Title := ComputeAppTitle;
> end;
>
> I've also seen it done like this:
>
> with Application do
>    Title := ComputeAppTitle;
>
> Also, the IDE is less apt to get confused if you keep code in the main 
> begin-end block to a minimum. I put most of the other code in separate 
> routines that I call from the main block. (But "Application.Title" can't 
> appear in those other DPR routines, either. Putting them in a separate 
> unit is fine.)
>
>   


------------------------------

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi


End of Delphi Digest, Vol 55, Issue 1
*************************************





       
____________________________________________________________________________________Ready
 for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to