TIP: Click on subject to list as thread! ANSI
echo: delphi
to: ALL
from: BRYAN SMITH
date: 1997-05-01 10:52:00
subject: Need insight into object behaviour.

I recently had a (Delphi 1) problem - the program GPF'ed whenever it exited.
Debugging revealed that the problem lay in the area of a FontDialog.  The
program had a TFont variable named BodyFont which was created by the Form's
FormCreate handler and freed by the Form's FormDestroy handler.
The problem code turned out to be the assignment statement in ...
  If FontDialog1.Execute then
  begin
    BodyFont := FontDialog1.Font ;
  end ;
The compiler accepts that, and it even had the desired effect on the fonts
while the program was still running.  However, digging around in the VCL
source code for DIALOGS.PAS suggested that ...
    BodyFont.Assign(FontDialog.Font) ;
might be more appropriate. Happily, this fixed the problem. Sadly, this use
of an object's "Assign" method is very poorly documented.
Can anybody provide some insight into what is going on here ? Did assigning
FontDialog.Font to Bodyfont and then freeing Bodyfont have the effect of
freeing FontDialog.Font, which was not supposed to be freed ? I'm guessing
that the "TFont" variables that we create (and all other such T-Types) are
not really T-variables at all, but really pointers to such variables - i.e.
they are equivlaent to the P-variables of older Turbo Pascal.
Just to confuse the issue, I read in "Delphi 2 Developer's Guide" by Pacheco
and Teixeira that "Under Win32, GDI objects are not shared as are their
16-bit counterparts. GDI objects are stored in the process's address space
instead of a globally accessible memory block". Is this relevant to the
problem, and to whether it is also a problem in Delphi 2 ?
--- PPoint 2.00
---------------
* Origin: Kingston, Canada (1:249/109.11)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.