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.