unit exprn;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtDlgs, extctrls, stdctrls, CommDlg, Dlgs,ComCtrls;
type
TExtendedPrintDialog = class(TPrintDialog) //определяем новый класс из родительского
private
fExtendedPanel: TPanel; // определяем новые компоненты
flabel,flabel2: TLabel;
ftedit: TEdit;
protected
procedure DoShow; override;
function GetStaticRect: TRect;
function TaskModalDialog(DialogFunc: Pointer; var DialogData): Bool;
override;
public
constructor Create(AOwner: TComponent); override;
function Execute: Boolean; override;
end;
implementation
constructor TExtendedPrintDialog.Create(AOwner: TComponent); //создаём новые компоненты
begin
inherited; //несовсем понял этот оператор :-(
fExtendedPanel := TPanel.Create(Self); //создали панель на которой всё рисуем
with fExtendedPanel do
begin
Name := 'ExtendedPanel';
Caption := '';
SetBounds(0, 0, 169, 200); // (204, 5, 169, 200);
BevelOuter := bvNone;
BorderWidth := 6;
TabOrder := 1;
flabel := TLabel.Create(Self); //комент к полю ввода
with flabel do
begin
Name := 'SomeLabel';
Caption := 'Масштаб ';
SetBounds(0, 7, 50, 21);
Parent := fExtendedPanel;
end;
flabel2 := TLabel.Create(Self);
with flabel2 do
begin
Name := 'SomeButt'; //знак процента в конце
Caption := '%';
SetBounds(80, 7, 20, 21);
Parent := fExtendedPanel;
end;
ftedit := TEdit.Create(Self);
with ftedit do
begin
Name := 'EditProcent'; //само поле ввода
Caption := '';
SetBounds(50, 3, 25, 21);
Parent := fExtendedPanel;
Text:='100';
MaxLength:=3;
end;
end
end;
procedure TExtendedPrintDialog.DoShow;
var
PreviewRect, StaticRect: TRect;
begin
{ Set preview area to entire dialog }
GetClientRect(Handle, PreviewRect);
StaticRect := GetStaticRect;
{ Move extended area to right of static area }
PreviewRect.Left := StaticRect.Left;
PreviewRect.Top := StaticRect.Bottom;
Inc(PreviewRect.Top, 4);
fExtendedPanel.BoundsRect := PreviewRect;
fExtendedPanel.ParentWindow := Handle;
inherited DoShow;
end;
//---------------------------------- это добавил я
procedure TExtendedPrintDialog.DoClose;
begin
//переношу данные из этого места в главную форму
Form1.Edit1.Text:=ftedit.Text; //вот и всё
end;
//------------------------------------
function TExtendedPrintDialog.Execute: Boolean;
begin
Template := 'DLGTEMPLATE';// this is in the extdlgs.rc
Result := inherited Execute;
end;
function TExtendedPrintDialog.GetStaticRect: TRect;
begin
if Handle <> 0 then
begin
GetWindowRect(GetDlgItem(Handle, grp1), Result); // print range group box
MapWindowPoints(0, Handle, Result, 2);
end
else
Result := Rect(0, 0, 0, 0)
end;
function TExtendedPrintDialog.TaskModalDialog(DialogFunc: Pointer;
var DialogData): Bool;
begin
TPrintDlg(DialogData).Flags := TPrintDlg(DialogData).Flags or
PD_ENABLESETUPTEMPLATE;
TPrintDlg(DialogData).lpSetupTemplateName := Template;
Result := inherited TaskModalDialog(DialogFunc, DialogData);
end;
end.