Recent

Author Topic: Question about Themes.pas and TWinControl.Canvas  (Read 3757 times)

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Question about Themes.pas and TWinControl.Canvas
« on: February 08, 2013, 02:28:28 pm »
Maybe someone that is familiar with Themes.pas can explain to me what this code does.  The reason I ask is because when I mirror TWinControl for RightToLeftLayout, TWinControl.Canvas is corrupted and can not be used.

Code: [Select]
procedure TThemeServices.UpdateThemes;
begin
  if FUseThemes then
    UnloadThemeData;
  FUseThemes := UseThemes;
  if FUseThemes then
    FThemedControlsEnabled := ThemedControlsEnabled
  else
    FThemedControlsEnabled := False;
end;

If I change the code as follows, everything seems to work correctly and the Canvas is fine, but I'm not sure about any side effects.  It may have effects that I don't know about.

Code: [Select]
procedure TThemeServices.UpdateThemes;
begin
  if FUseThemes then
    UnloadThemeData;
  FUseThemes := UseThemes;

  //if FUseThemes then
  //  FThemedControlsEnabled := ThemedControlsEnabled
  //else
    FThemedControlsEnabled := False;
end;

Edit:  I found one of the side effects.  Some TGraphicControls are drawn differently with my changes.  I.E. TSpeedButton has square corners.  But for me, this is a very small price to pay to be able to produce RightToLeft Forms.
« Last Edit: February 18, 2013, 11:23:54 am by Avishai »
Lazarus Trunk / fpc 2.6.2 / Win32

Bart

  • Hero Member
  • *****
  • Posts: 5663
    • Bart en Mariska's Webstek
Re: Question about Themes.pas and TWinControl.Canvas
« Reply #1 on: February 09, 2013, 02:24:09 pm »
Well, basically you are disabling themes...

Bart

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Question about Themes.pas and TWinControl.Canvas
« Reply #2 on: February 09, 2013, 03:38:31 pm »
Well I sure hope so.  At least that is my intent.  What I don't understand is this. 

If I disable Themes by un-checking "Use manifest file to enable themes" in Project Options, it affects the drawing on almost all controls. 

If I disable Themes in "procedure TThemeServices.UpdateThemes;" it looks like only TGraphicControls are drawn differently.
Lazarus Trunk / fpc 2.6.2 / Win32

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Question about Themes.pas and TWinControl.Canvas
« Reply #3 on: February 11, 2013, 08:47:08 am »
What I'm really looking for is a way to fix Themes so that it doesn't corrupt TCanvas when RightToLeftLayout is used.
Lazarus Trunk / fpc 2.6.2 / Win32

 

TinyPortal © 2005-2018