AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

[XE4] Styles, TListbox und WS_EX_COMPOSITED

Ein Thema von 4dk2 · begonnen am 1. Dez 2015 · letzter Beitrag vom 1. Dez 2015
Antwort Antwort
4dk2

Registriert seit: 4. Sep 2007
176 Beiträge
 
#1

[XE4] Styles, TListbox und WS_EX_COMPOSITED

  Alt 1. Dez 2015, 14:18
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.
Angehängte Dateien
Dateityp: zip XEStyleTest_Listbox.zip (139,9 KB, 2x aufgerufen)
  Mit Zitat antworten Zitat
4dk2

Registriert seit: 4. Sep 2007
176 Beiträge
 
#2

AW: [XE4] Styles, TListbox und WS_EX_COMPOSITED

  Alt 1. Dez 2015, 15:18
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))
  Mit Zitat antworten Zitat
4dk2

Registriert seit: 4. Sep 2007
176 Beiträge
 
#3

AW: [XE4] Styles, TListbox und WS_EX_COMPOSITED

  Alt 1. Dez 2015, 15:30
OK, den Fehler gefunden, wie man ihn löst aber nicht.

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


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:03 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