Page 1 of 1

dfm Property

Posted: Wed Apr 03, 2019 3:15 pm
by 17585969
Hi:

.dfm shows DefaultCanvas := 'TGDIPlusCanvas';

TChart has no such property as DefaultCanvas but only a DelphiCanvas.

Why doesn't this pop up an error?

Thanks

Re: dfm Property

Posted: Thu Apr 04, 2019 8:00 am
by yeray
Hello,

There's a private property in TCustomTeePanel named IDefaultCanvas. And at TCustomTeePanel.Create constructor you'll find this to use the value from the registry:

Code: Select all

Constructor TCustomTeePanel.Create(AOwner: TComponent);
begin
  inherited;
  //...
  
  // For new charts, set default canvas whatever is at the Registry,
  // or use the class indicated by TeeDefaultCanvas global variable,
  // which is (in VCL) the GDI+ canvas by default.

  // Setting TeeDefaultCanvas:='' will not look at registry, and will not
  // use VCL GDI+

  if (TeeDefaultCanvas<>'') and
     (not (csLoading in ComponentState)) then
     IDefaultCanvas:=TeeReadStringOption('DefaultCanvas',TeeDefaultCanvas)
  else
     IDefaultCanvas:=''; // Existing old charts saved in dfm/fmx, no change

  CreateDefaultCanvas;
  //...
end;
Then, to read the DefaultCanvas property from the dfm we use this:

Code: Select all

Procedure TCustomTeePanel.DefineProperties(Filer:TFiler);

  function DoWriteDefaultCanvas:Boolean;
  begin
    result:=(Filer.Ancestor=nil) or
            (IDefaultCanvas<>TCustomTeePanel(Filer.Ancestor).IDefaultCanvas);
  end;

begin
  inherited;

  //...
  Filer.DefineProperty('DefaultCanvas',ReadDefaultCanvas,WriteDefaultCanvas,
        {$IFDEF FMX}False{$ELSE}DoWriteDefaultCanvas{$ENDIF});
end;

procedure TCustomTeePanel.ReadDefaultCanvas(Reader: TReader);
begin
  IDefaultCanvas:=Reader.ReadString;
  {$IFDEF FMX}
  IDefaultCanvas:=''; // Switching canvas is not supported yet in FireMonkey
  {$ENDIF}
end;
I hope this explains your doubt.