相关疑难解决方法(0)

在Delphi中进行非闪烁,分段图形更新的最佳方法是什么?

我想我可以把它扔到那里然后问:我已经看到Delphi控件在图形效果方面完美无缺.含义:没有闪烁,分段更新(仅重绘标记为脏的控件部分)和平滑滚动.

我已经编写了很多多年来图形控制的,所以我知道双缓冲,DIBS,bitblts和所有的"共同"的东西(我一直使用的DIB如果可能的话绘制的一切,但有一个开销).还要了解InvalidateRect并检查需要更新的实际rect的TCanvas.ClipRect.尽管有这些典型的解决方案,但我发现创建与Developer Express或Razed Components相同质量的组件非常困难.如果图形是平滑的,你可以打赌滚动条(本机)闪烁,如果滚动条和框架是平滑的,你可以在滚动期间发誓背景闪烁.

是否有标准的代码设置来处理这个问题?一种确保平滑重绘整个控件的最佳实践 - 包括控件的非客户区域?

例如,这是一个"裸骨"控件,它为分段更新占用高度(仅重绘所需的内容).如果在表单上创建它,请尝试在其上移动一个窗口,然后观察它用颜色替换部件(请参阅绘制方法).

有没有人有类似的基类可以处理非客户区重绘而不闪烁?

type

TMyControl = Class(TCustomControl)
private
  (* TWinControl: Erase background prior to client-area paint *)
  procedure WMEraseBkgnd(var Message: TWmEraseBkgnd);message WM_ERASEBKGND;
Protected
  (* TCustomControl: Overrides client-area paint mechanism *)
  Procedure Paint;Override;

  (* TWinControl: Adjust Win32 parameters for CreateWindow *)
  procedure CreateParams(var Params: TCreateParams);override;
public
  Constructor Create(AOwner:TComponent);override;
End;


{ TMyControl }

Constructor TMyControl.Create(AOwner:TComponent);
Begin
  inherited Create(Aowner);
  ControlStyle:=ControlStyle - [csOpaque];
end;

procedure TMyControl.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);

  (* When a window has this style …
Run Code Online (Sandbox Code Playgroud)

delphi graphics winapi

45
推荐指数
4
解决办法
1万
查看次数

CreateWnd和CreateWindowHandle有什么区别?

Delphi组件有CreateWndCreateWindowHandle(DestroyWndDestroyWindowHandle).它们都打算被后代覆盖,对吧?除了底层的VCL实现之外,不打算调用它?

它们之间有什么区别; 什么时候应该被覆盖?

delphi components

23
推荐指数
1
解决办法
4823
查看次数

“控件”没有父窗口”错误

当我将控件放在窗体上时,出现此错误。错误出现在这里:

  TAssociateFileExt = class(TGroupBox)
  private
  protected
  public
    btnAssociate   : TButton;
    constructor Create(aOwner: TComponent); override;
  end;

constructor TAssociateFileExt.Create(aOwner: TComponent);
begin
 inherited Create(aOwner);
 Caption:= '';                       <-------- error here
 ClientHeight:= 125;                 <-------- and here
 ClientWidth := 170;
 DoubleBuffered:= TRUE;

 btnAssociate:= TButton.Create(Self);
 btnAssociate.Parent:= Self;
 btnAssociate.Visible:= TRUE;
 btnAssociate.Left:= 17;
 btnAssociate.Top:= 26;
 btnAssociate.Width:= 142;
 btnAssociate.Height:= 25;
 btnAssociate.Hint:= 'Associate this application with its files. When you double click a file this program will automatically start and load that file.';
 btnAssociate.Caption:= 'Associate';
 btnAssociate.DoubleBuffered:= TRUE;
 btnAssociate.ParentDoubleBuffered:= FALSE;
 btnAssociate.TabOrder:= 0; …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-xe

5
推荐指数
1
解决办法
1万
查看次数

Delphi销毁动态控制onDestroy的父窗体

如何确保动态控件及其父窗体被销毁?

因此,从主窗体中,我为辅助窗体创建一个按钮,然后显示带有该按钮的辅助窗体。

现在,我要确保创建的按钮与辅助表单一起被销毁。

将按钮的父级设置为辅助表单就足够了吗?这样会吗?

我正在使用TButton类的自定义后代-TMyButton。所以在我的构造函数中,我有以下代码:

constructor TMyButton.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   Self.OnClick := Self.MyButtonClick;
   Self.Parent:=TWinControl(AOwner);
   self.Visible := true;
end;
Run Code Online (Sandbox Code Playgroud)

这样可以吗?它对我有用,它不会引发任何错误,但是我要确保所述按钮和放置它的表单一起被销毁。

MyButton将被放置在第二个表单上,比如说“ Form2”,因此将有如下代码:

var
  bt:TMyButton;
begin
      bt:=TMyButton.Create(Form2);
      bt.Parent:=Form2;
      ...
      form2.Show;
end;
Run Code Online (Sandbox Code Playgroud)

delphi

1
推荐指数
1
解决办法
986
查看次数

标签 统计

delphi ×4

components ×1

delphi-xe ×1

graphics ×1

winapi ×1