Einzelnen Beitrag anzeigen

NielsB

Registriert seit: 4. Mär 2016
17 Beiträge
 
#17

AW: Panel mit vielen Buttons baut sich langsam auf

  Alt 5. Mär 2016, 11:52
Zunächst vielen Dank für die vielen Vorschläge, ich habe versucht, alles auszuprobieren (mit aktuellen Treibern) - leider ohne Erfolg. Zunächst nochmal das Problem in Videoform, vielleicht wird es dann deutlicher: Video

Die Aufnahmen sind stark verlangsamt, um den Aufbau deutlich erkennen zu können. In Echtzeit ist es in dieser Testunit nur zu erkennen, wenn man drauf achtet, aber mit der eigentlichen Applikationslogik im Hintergrund und zusätzlichen Styles wird das Problem sehr deutlich sichtbar.

Die Methoden scheinen sich nicht signifikant zu unterscheiden und der eigentliche Bildaufbau ist immer ein Vorgang, der sich sichtbar über den Bildschirm bewegt. Ist es überhaupt möglich, dies zu verhindern?

Der Code(habe leider keine Spoilertags gefunden):
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.Buttons, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    BitBtn42: TBitBtn;
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    BitBtn9: TBitBtn;
    BitBtn10: TBitBtn;
    BitBtn11: TBitBtn;
    BitBtn12: TBitBtn;
    BitBtn13: TBitBtn;
    BitBtn14: TBitBtn;
    BitBtn15: TBitBtn;
    BitBtn16: TBitBtn;
    BitBtn17: TBitBtn;
    BitBtn18: TBitBtn;
    BitBtn19: TBitBtn;
    BitBtn20: TBitBtn;
    BitBtn21: TBitBtn;
    BitBtn22: TBitBtn;
    BitBtn23: TBitBtn;
    BitBtn24: TBitBtn;
    BitBtn25: TBitBtn;
    BitBtn26: TBitBtn;
    BitBtn27: TBitBtn;
    BitBtn28: TBitBtn;
    BitBtn29: TBitBtn;
    BitBtn30: TBitBtn;
    BitBtn31: TBitBtn;
    BitBtn32: TBitBtn;
    BitBtn33: TBitBtn;
    BitBtn34: TBitBtn;
    BitBtn35: TBitBtn;
    BitBtn36: TBitBtn;
    BitBtn37: TBitBtn;
    BitBtn38: TBitBtn;
    BitBtn39: TBitBtn;
    BitBtn40: TBitBtn;
    BitBtn41: TBitBtn;
    BitBtn43: TBitBtn;
    BitBtn44: TBitBtn;
    BitBtn45: TBitBtn;
    BitBtn46: TBitBtn;
    procedure BitBtn42Click(Sender: TObject);
    procedure BitBtn44Click(Sender: TObject);
    procedure BitBtn45Click(Sender: TObject);
    procedure BitBtn46Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn42Click(Sender: TObject);
var
I : Integer;
handle : HWND;
begin
  handle := BeginDeferWindowPos(1);
  DeferWindowPos(handle,Panel1.Handle,HWND_TOP,0,0,640,480,$0001);
  EndDeferWindowPos(handle);
end;

procedure TForm1.BitBtn44Click(Sender: TObject);
begin
  Panel1.Left := 640;
end;

procedure TForm1.BitBtn45Click(Sender: TObject);
begin
  Panel1.Left := 0;
end;

procedure TForm1.BitBtn46Click(Sender: TObject);
begin
  SendMessage(Panel1.Handle, WM_SETREDRAW, 0, 0);
try
  Panel1.Left:= Form1.Width + 1; // Sollte natürlich das Formular sein auf dem das Panel liegt.
  Panel1.Top:=0;
  Panel1.Visible:=True;
  Panel1.Left:= 0;
finally
  SendMessage(Panel1.Handle, WM_SETREDRAW, 1, 0);
  RedrawWindow(Panel1.Handle, nil, 0, RDW_ERASE or RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN);
end;

end;

end.
Delphi-Quellcode:
object Form1: TForm1
  Left = 0
  Top = 0
  BorderStyle = bsNone
  Caption = 'Form1'
  ClientHeight = 480
  ClientWidth = 640
  Color = clBtnFace
  DoubleBuffered = True
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Scaled = False
  PixelsPerInch = 96
  TextHeight = 13
  object BitBtn42: TBitBtn
    Left = 8
    Top = 228
    Width = 97
    Height = 25
    Caption = 'DeferWindowsPos'
    TabOrder = 0
    OnClick = BitBtn42Click
  end
  object Panel1: TPanel
    Left = 640
    Top = 0
    Width = 640
    Height = 480
    Caption = 'Panel1'
    FullRepaint = False
    TabOrder = 1
    object BitBtn1: TBitBtn
      Left = 16
      Top = 16
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 0
    end
    object BitBtn2: TBitBtn
      Left = 16
      Top = 47
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 1
    end
    object BitBtn3: TBitBtn
      Left = 16
      Top = 78
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 2
    end
    object BitBtn4: TBitBtn
      Left = 16
      Top = 109
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 3
    end
    object BitBtn5: TBitBtn
      Left = 16
      Top = 140
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 4
    end
    object BitBtn6: TBitBtn
      Left = 16
      Top = 171
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 5
    end
    object BitBtn7: TBitBtn
      Left = 16
      Top = 202
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 6
    end
    object BitBtn8: TBitBtn
      Left = 16
      Top = 233
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 7
    end
    object BitBtn9: TBitBtn
      Left = 16
      Top = 264
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 8
    end
    object BitBtn10: TBitBtn
      Left = 16
      Top = 295
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 9
    end
    object BitBtn11: TBitBtn
      Left = 16
      Top = 326
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 10
    end
    object BitBtn12: TBitBtn
      Left = 16
      Top = 357
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 11
    end
    object BitBtn13: TBitBtn
      Left = 16
      Top = 388
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 12
    end
    object BitBtn14: TBitBtn
      Left = 16
      Top = 419
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 13
    end
    object BitBtn15: TBitBtn
      Left = 224
      Top = 16
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 14
    end
    object BitBtn16: TBitBtn
      Left = 224
      Top = 295
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 15
    end
    object BitBtn17: TBitBtn
      Left = 224
      Top = 326
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 16
    end
    object BitBtn18: TBitBtn
      Left = 224
      Top = 357
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 17
    end
    object BitBtn19: TBitBtn
      Left = 224
      Top = 388
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 18
    end
    object BitBtn20: TBitBtn
      Left = 224
      Top = 419
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 19
    end
    object BitBtn21: TBitBtn
      Left = 224
      Top = 47
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 20
    end
    object BitBtn22: TBitBtn
      Left = 224
      Top = 78
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 21
    end
    object BitBtn23: TBitBtn
      Left = 224
      Top = 109
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 22
    end
    object BitBtn24: TBitBtn
      Left = 224
      Top = 140
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 23
    end
    object BitBtn25: TBitBtn
      Left = 224
      Top = 171
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 24
    end
    object BitBtn26: TBitBtn
      Left = 224
      Top = 202
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 25
    end
    object BitBtn27: TBitBtn
      Left = 224
      Top = 233
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 26
    end
    object BitBtn28: TBitBtn
      Left = 224
      Top = 264
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 27
    end
    object BitBtn29: TBitBtn
      Left = 440
      Top = 16
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 28
    end
    object BitBtn30: TBitBtn
      Left = 440
      Top = 295
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 29
    end
    object BitBtn31: TBitBtn
      Left = 440
      Top = 326
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 30
    end
    object BitBtn32: TBitBtn
      Left = 440
      Top = 357
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 31
    end
    object BitBtn33: TBitBtn
      Left = 440
      Top = 388
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 32
    end
    object BitBtn34: TBitBtn
      Left = 440
      Top = 419
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 33
    end
    object BitBtn35: TBitBtn
      Left = 440
      Top = 47
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 34
    end
    object BitBtn36: TBitBtn
      Left = 440
      Top = 78
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 35
    end
    object BitBtn37: TBitBtn
      Left = 440
      Top = 109
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 36
    end
    object BitBtn38: TBitBtn
      Left = 440
      Top = 140
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 37
    end
    object BitBtn39: TBitBtn
      Left = 440
      Top = 171
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 38
    end
    object BitBtn40: TBitBtn
      Left = 440
      Top = 202
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 39
    end
    object BitBtn41: TBitBtn
      Left = 440
      Top = 233
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 40
    end
    object BitBtn43: TBitBtn
      Left = 440
      Top = 264
      Width = 177
      Height = 25
      Caption = 'BitBtn1'
      TabOrder = 41
    end
    object BitBtn44: TBitBtn
      Left = 224
      Top = 450
      Width = 177
      Height = 25
      Caption = 'Panel ausblenden'
      TabOrder = 42
      OnClick = BitBtn44Click
    end
  end
  object BitBtn45: TBitBtn
    Left = 128
    Top = 228
    Width = 75
    Height = 25
    Caption = 'Left:=0'
    TabOrder = 2
    OnClick = BitBtn45Click
  end
  object BitBtn46: TBitBtn
    Left = 232
    Top = 228
    Width = 75
    Height = 25
    Caption = 'SendMessage'
    TabOrder = 3
    OnClick = BitBtn46Click
  end
end
  Mit Zitat antworten Zitat