如何在OpenDialog界面上加上一点自己的东西?(20分)

  • 主题发起人 主题发起人 flai
  • 开始时间 开始时间
F

flai

Unregistered / Unconfirmed
GUEST, unregistred user!
在OpenDialog执行时,显示的界面上,除了本身的那些东西,
我还想放上一点自己的东西,就像Photoshop打开文件时一样,
可以预览图像。

怎样可以实现这一点?
 
可以参考Delphi中的TPictureOpenDialog和TPictureSaveDialog的源代码.
在$Delphi/source/vcl中.
 
自己做个对话框啦
 
继承TpenDialog,在create中做你想做的事
 
我参照TPictureOpenDialog写了一个类似的OpenDialog,结果却不如愿,
在procedure DoShow中,GetClientRect时返回的Rect总是 top=0,bottom=0,left=0
为什么,望高人指点,谢谢。

代码如下:

unit RepOpenDialog;

interface

Uses
Dialogs,graphics,extctrls,stdctrls,buttons,classes,Controls,
consts,Windows,Sysutils,forms;
Type
TRepOpenDialog = class(TOpenDialog)
private
FCheckPanel: TPanel;
FChkDrawHLine:TCheckBox;
FChkDrawVLine:TCheckBox;
protected
procedure DoClose; override;
procedure DoShow; override;
published
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;

procedure Register;
implementation

constructor TRepOpenDialog.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FCheckPanel := TPanel.Create(Self);
with FCheckPanel do
begin
Name := 'CheckPanel';
Caption := '';
SetBounds(204, 5, 169, 200);
BevelOuter := bvNone;
BorderWidth := 6;
TabOrder := 1;
FChkDrawHLine := TCheckBox.Create(Self);
FChkDrawVLine := TCheckBox.Create(Self);
with FChkDrawHLine do
begin
Name := 'ChkDrawHLine';
Caption := '';
SetBounds(6, 6, 157, 23);
Align := alTop;
AutoSize := False;
Parent := FCheckPanel;
end;
with FChkDrawVLine do
begin
Name := 'ChkDrawVLine';
Caption := '';
SetBounds(6, 6, 157, 23);
Align := alTop;
AutoSize := False;
Parent := FCheckPanel;
end;
end;
end;

destructor TRepOpenDialog.Destroy;
begin
FChkDrawHLine.Free;
FChkDrawVLine.Free;
FCheckPanel.Free;
inherited Destroy;
end;
procedure TRepOpenDialog.DoClose;
begin
inherited DoClose;
{ Hide any hint windows left behind }
Application.HideHint;
end;

procedure TRepOpenDialog.DoShow;
var
PreviewRect, StaticRect: TRect;
begin
{ Set preview area to entire dialog }
GetClientRect(Handle, PreviewRect);
StaticRect := GetStaticRect;
{ Move preview area to right of static area }
PreviewRect.Left := StaticRect.Left + (StaticRect.Right - StaticRect.Left);
Inc(PreviewRect.Top, 4);
FCheckPanel.BoundsRect := PreviewRect;
FCheckPanel.ParentWindow := Handle;
inherited DoShow;
end;
procedure Register;
begin
RegisterComponents('Standard', [TRepOpenDialog]);
end;
end.
 
如果直接在FORM中画个对话框也不错啊!
 
flai:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。
 
多人接受答案了。
 
后退
顶部