size : 1768
uploaded_on : Tue May 11 00:00:00 1999
modified_on : Wed Dec 8 14:03:40 1999
title : Own form extension on TOpenDialog
org_filename : OpenDlgForm.txt
author : Hamish Williams
authoremail : hamish.williams@dial.pipex.com
description : Extending TOpenDialog with own forms
keywords :
tested : not tested yet
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : nobody
modified_by : nobody
owner : nobody
lang : plain
file-type : text/plain
category : delphi-components
__END_OF_HEADER__
Here's a snippet that allows you to design a form within Delphi's
IDE. Assign that form's class to your open dialog's BottomFormClass (at
runtime, I'm afraid). Then, when the DoShow event is triggered, an instance of
your designed form is added to the bottom of the dialog box.
ThOpenDialog = class(TOpenDialog)
private
FBottomFormClass : TFormClass;
FBottomForm : TForm;
protected
procedure DoClose; override;
procedure DoShow; override;
procedure SetBottomFormClass(NewFormClass : TFormClass);
published
property BottomFormClass : TFormClass read FBottomFormClass write
SetBottomFormClass;
{ This does not display in the inspector. Must be set
by code. }
end;
procedure ThOpenDialog.DoClose;
begin
inherited;
if Assigned(FBottomForm) then
begin
FBottomForm.Free;
FBottomForm := nil
end
end;
procedure ThOpenDialog.DoShow;
var
ParentWindow : HWND;
Rect : TRect;
begin
inherited;
if Assigned(FBottomFormClass) then
begin
ParentWindow := GetParent(Handle);
FBottomForm := FBottomFormClass.CreateParented(ParentWindow);
FBottomForm.BorderStyle := bsNone;
{ Position the form at the bottom of the dialog box. }
GetClientRect(ParentWindow, Rect);
FBottomForm.Top := Rect.Bottom;
FBottomForm.Left := 0;
FBottomForm.Show;
{ Expand the dialog box to include space for the form. }
GetWindowRect(ParentWindow, Rect);
MoveWindow(ParentWindow, Rect.Left, Rect.Top, Rect.Right - Rect.Left,
Rect.Bottom - Rect.Top + FBottomForm.Height - 20, True)
end
end;
procedure ThOpenDialog.SetBottomFormClass(NewFormClass : TFormClass);
begin
FBottomFormClass := NewFormClass
end;