Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi [XE4] Styles, TListbox und WS_EX_COMPOSITED (https://www.delphipraxis.net/187454-%5Bxe4%5D-styles-tlistbox-und-ws_ex_composited.html)

4dk2 1. Dez 2015 14:18

[XE4] Styles, TListbox und WS_EX_COMPOSITED
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo zusammen,
meine Anwendung soll einen Standart Style von Delphi. (z.b. Auric) bekommen.
Nun habe das problem, dass ich gerne alle Controls mit der Option WS_EX_COMPOSITED ausstatten würde.
Warum?
Durch diverse experimente mit den Styles ist herausgekommen, dass durch das WS_EX_COMPOSITED flag das zeichnen der Controls wesentlich schneller abläuft,
und auch flackern, z.b. bei resize, show/hide beseitigt wird. (gibt da diverse Artikel via Google)

Bisher ist auch alles Ok, bis auf die TListbox.

Wenn ich bei der, oder z.b. einem Parent Panel die option setzte, wird die listbox nicht mehr richtig gezeichnet und die Anwendung reagiert teilweise garnicht mehr.
Jedoch erst wenn die Scrollbars sichtbar werden!

Hier der Code (oder im anhang das gesamte TestProjekt)

Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Panel3: TPanel;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure SetComposited(WinControl: TWinControl; Value: boolean);
var
  ExStyle, NewExStyle: DWORD;
begin
  if WinControl.InheritsFrom(TCustomForm) then exit;
  if WinControl.InheritsFrom(TCustomListBox) then exit;

  ExStyle := GetWindowLong(WinControl.Handle, GWL_EXSTYLE);
  if Value then
  begin
    NewExStyle := ExStyle or WS_EX_COMPOSITED;
  end
  else
  begin
    NewExStyle := ExStyle and not WS_EX_COMPOSITED;
  end;
  if NewExStyle <> ExStyle then
  begin
    SetWindowLong(WinControl.Handle, GWL_EXSTYLE, NewExStyle);
  end;
end;


procedure SetAllComposited(WinControl: TWinControl;AValue:boolean);
var
  i: Integer;
  NewExStyle: DWORD;
begin
  //ifs für fehler bei listbox...
  if not WinControl.InheritsFrom(TListBox) then //das bringt nix...
  if not WinControl.InheritsFrom(TCustomForm) then //das bringt nix...
    SetComposited(WinControl, AValue);
  for i := 0 to WinControl.ControlCount-1 do
    if WinControl.Controls[i] is TWinControl then
      SetAllComposited(TWinControl(WinControl.Controls[i]),AValue);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;

begin
  SetComposited(Panel1,true);
  SetComposited(self,true);
  SetComposited(ListBox1,false);
  for I := 1 to 200 do
    ListBox1.AddItem('asd',nil);
end;

end.

4dk2 1. Dez 2015 15:18

AW: [XE4] Styles, TListbox und WS_EX_COMPOSITED
 
falls es jemandem hilft, ich hab die WndProc von der TCustomlistbox danach mal gepatch und hier ein auszug aus den messages die da permanent runter rattern:
Delphi-Quellcode:
------------ After Button1 Click --------------
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: B5011986 (-1258219130), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: B5011986 (-1258219130), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 72011C1C (1912675356), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: B5011986 (-1258219130), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: B5011986 (-1258219130), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 9101182F (-1862199249), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: D01149C (218174620), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: D01149C (218174620), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: B5011986 (-1258219130), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: A7011819 (-1493100519), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: A7011819 (-1493100519), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: D01149C (218174620), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: A7011819 (-1493100519), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: A7011819 (-1493100519), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 7F010FC2 (2130776002), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: A7011819 (-1493100519), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: A7011819 (-1493100519), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 350111DE (889262558), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: BC011497 (-1140779881), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: BC011497 (-1140779881), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: A7011819 (-1493100519), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: 96011022 (-1778315230), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 96011022 (-1778315230), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: BC011497 (-1140779881), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 3A010C5F (973147231), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: BC011497 (-1140779881), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: A7011819 (-1493100519), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: 350111DE (889262558), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: 7F010FC2 (2130776002), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: D01149C (218174620), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: B5011986 (-1258219130), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: 9101182F (-1862199249), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
CN_CTLCOLORLISTBOX (WParam: 72011C1C (1912675356), LParam: 9040E (590862))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 45040D77 (1157893495), LParam: 0 (0))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: 81010BE9 (-2130637847), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: 81010BE9 (-2130637847), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: B5011986 (-1258219130), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: B5011986 (-1258219130), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: B5011986 (-1258219130), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))
WM_ERASEBKGND (WParam: E001103E (-536801218), LParam: 0 (0))
CN_CTLCOLORLISTBOX (WParam: E001103E (-536801218), LParam: 9040E (590862))
WM_ERASEBKGND (WParam: E001103E (-536801218), LParam: 0 (0))
WM_NCPAINT (WParam: 1 (1), LParam: 0 (0))
WM_PAINT (WParam: 0 (0), LParam: 0 (0))

4dk2 1. Dez 2015 15:30

AW: [XE4] Styles, TListbox und WS_EX_COMPOSITED
 
OK, den Fehler gefunden, wie man ihn löst aber nicht.

Listbox1.StyleElements = [seFont, seClient] (also ohne seBorder)
und es geht.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz