我试图避免闪烁,所以我决定使用透明表格。问题是表格没有正确绘制。
问题是如何正确地绘制表格而不闪烁?如果我隐藏以前的透明表单并在其位置显示新表单,则解决方案应该有效。
这是主要表格
unit Main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls,
Transparent1, Vcl.StdCtrls, Vcl.Buttons;
type
TfrmMain = class(TForm)
imgBackground: TImage;
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
FfrmTransparent1: TfrmTransparent1;
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
uses
JPEG;
procedure TfrmMain.BitBtn1Click(Sender: TObject);
begin
FfrmTransparent1.Show;
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
imgBackground.Align := alClient;
imgBackground.Picture.LoadFromFile('butterfly-wallpaper.jpeg');
Self.WindowState := TWindowState.wsMaximized;
FfrmTransparent1:= TfrmTransparent1.Create(nil);
FfrmTransparent1.Parent := Self;
FfrmTransparent1.Left := 10;
FfrmTransparent1.Top := 20;
//FfrmTransparent1.Show;
//FfrmTransparent1.Update;
end;
end.
DFM
object frmMain: TfrmMain
Left = 0
Top = 0
Caption = 'frmMain'
ClientHeight = 423
ClientWidth = 624
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object imgBackground: TImage
Left = 120
Top = 152
Width = 105
Height = 105
end
object BitBtn1: TBitBtn
Left = 541
Top = 16
Width = 75
Height = 25
Caption = 'BitBtn1'
TabOrder = 0
OnClick = BitBtn1Click
end
end
透明表格
unit Transparent1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TfrmTransparent1 = class(TForm)
imgButterfly: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
uses
PNGImage;
procedure TfrmTransparent1.FormCreate(Sender: TObject);
begin
Brush.Style:=bsClear;
Self.BorderStyle := bsNone;
imgButterfly.Picture.LoadFromFile('Butterfly.png');
imgButterfly.Left := 20;
imgButterfly.Top := 30;
imgButterfly.Height := imgButterfly.Picture.Height;
imgButterfly.Width := imgButterfly.Picture.Width;
Self.Width := imgButterfly.Width + imgButterfly.Left;
Self.Height := imgButterfly.Top + imgButterfly.Height;
end;
end.
DFM
object frmTransparent1: TfrmTransparent1
Left = 0
Top = 0
Caption = 'frmTransparent1'
ClientHeight = 292
ClientWidth = 502
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object imgButterfly: TImage
Left = 16
Top = 16
Width = 217
Height = 89
end
end