加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Delphi XE2 VCL风格,更新字幕块其他控件无效

发布时间:2020-12-15 10:19:38 所属栏目:大数据 来源:网络整理
导读:发现与VCL样式的毛刺:当您更新表单标题时,以前在同一过程中重绘的其他控件不会重画,并且您被迫调用重绘,从而失去重绘的宝贵的处理时间。 示例:(手动设置项目选项/ vcl样式) unit Unit11;interfaceuses Winapi.Windows,Winapi.Messages,System.SysUtils,
发现与VCL样式的毛刺:当您更新表单标题时,以前在同一过程中重绘的其他控件不会重画,并且您被迫调用重绘,从而失去重绘的宝贵的处理时间。

示例:(手动设置项目选项/ vcl样式)

unit Unit11;

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
  TForm11 = class(TForm)
    Button1: TButton;
    Panel1: TPanel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form11: TForm11;

implementation

{$R *.dfm}

procedure TForm11.Button1Click(Sender: TObject);
begin
  Panel1.Caption := 'test';
  caption := 'glitch';
end;

end.

object Form11: TForm11
  Left = 0
  Top = 0
  Caption = 'Form11'
  ClientHeight = 89
  ClientWidth = 352
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 8
    Top = 8
    Width = 121
    Height = 57
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Panel1: TPanel
    Left = 135
    Top = 8
    Width = 185
    Height = 57
    Caption = 'Panel1'
    TabOrder = 1
  end
end

program Project10;

uses
  Vcl.Forms,Unit11 in 'Unit11.pas' {Form11},Vcl.Themes,Vcl.Styles;

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  TStyleManager.TrySetStyle('Cobalt XEMedia');
  Application.CreateForm(TForm11,Form11);
  Application.Run;
end.

解决方法

在序列中设置字幕调用。

>第一个form.caption,然后child.caption。

一旦你调用了错误的序列,然后停止工作正确的序列。这就是为什么我在这里,“设置默认”按钮。

这进行,只要没有修复它,我可以住在那里。

procedure TForm11.Button1Click(Sender: TObject);
begin // wrong order
  Panel1.Caption := 'test';
  caption := 'glitch';
end;

procedure TForm11.Button2Click(Sender: TObject);
begin // right order
  caption := 'glitch';
  Panel1.Caption := 'test';
end;

procedure TForm11.Button3Click(Sender: TObject);
var
i:integer;
begin // count no refresh
  for  i:= 1 to 300 do begin
  caption := 'glitch '+intToStr(i);
  Panel1.Caption := 'test '+intToStr(i);
  end;
end;

procedure TForm11.Button4Click(Sender: TObject);
var
i:integer;
begin // count with refresh
  for  i:= 1 to 300 do begin
  caption := 'glitch '+intToStr(i);
  Panel1.Caption := 'test '+intToStr(i);
  Panel1.Refresh;
  end;
end;

procedure TForm11.Button5Click(Sender: TObject);
begin // set default
  caption := 'Form11';
  Panel1.Caption := 'Panel1';
  Panel1.Refresh;
end;

end.

如果你找到另一个解决方案。请告诉我。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读