📄 ugdrep.pas
字号:
unit Ugdrep;
interface
uses Urepset, SysUtils, classes, Qrctrls, windows, registry, uRepselect, ExtCtrls, QuickRpt, Controls;
type
TPrinttype = (Prt_set, prt_view, Prt_print);
type
TPublicPrint = class(TComponent)
private
FSetupForm: TFrm_RepSet;
FRepSelect: TFrm_RepSelect;
FQuickRep: TQuickrep;
Fprinttype: TPrinttype;
procedure SetQuickRep(const Value: TQuickrep);
procedure Setup;
function No: string;
procedure setplace(sender: Tobject);
procedure Print(sender: Tobject);
procedure preview(sender: Tobject);
procedure Setprinttype(const Value: TPrinttype);
public
constructor create(Awoner: TComponent);
procedure GdPrint;
published
property QuickRep: TQuickrep read FQuickRep write SetQuickRep;
property printtype: TPrinttype read Fprinttype write Setprinttype;
end;
procedure Register;
implementation
{ TPublicPrint }
constructor TPublicPrint.create(Awoner: TComponent);
begin
inherited Create(AWoner);
end;
function TPublicPrint.No: string;
var
i, j, num: integer;
begin
num := 0;
for i := 0 to FQuickRep.ControlCount - 1 do
begin
if FQuickRep.Controls[i] is TQRBand then
begin
for j := 0 to (FQuickRep.Controls[i] as TQRBand).ControlCount - 1 do
inc(num);
end
else
if FQuickRep.Controls[i] is TQRChildBand then
begin
for j := 0 to (FQuickRep.Controls[i] as TQRChildBand).ControlCount - 1 do
inc(num);
end
else
if FQuickRep.Controls[i] is TQRsubdetail then
begin
for j := 0 to (FQuickRep.Controls[i] as TQRsubdetail).ControlCount - 1 do
inc(num);
end
else
if FQuickRep.Controls[i] is TQRStringsBand then
begin
for j := 0 to (FQuickRep.Controls[i] as TQRStringsBand).ControlCount - 1 do
inc(num);
end
else
begin
inc(num);
end;
end;
Result := inttostr(num);
end;
procedure TPublicPrint.GdPrint;
begin
if FSetupForm = nil then
FSetupForm := TFrm_RepSet.Create(nil);
FSetupForm.BitBtn2.OnClick := preview;
FSetupForm.BitBtn3.OnClick := print;
FSetupForm.OnActivate := setplace;
case Fprinttype of
Prt_set: begin
FRepSelect := TFrm_RepSelect.create(nil);
FRepSelect.ShowModal;
case FRepSelect.RadioGroup1.ItemIndex of
0: Setup;
1: preview(nil);
2: print(nil);
end;
FRepSelect.free;
end;
prt_view: preview(nil);
Prt_print: Print(nil);
end;
end;
procedure TPublicPrint.preview(sender: Tobject);
begin
setplace(nil);
QuickRep.Preview;
end;
procedure TPublicPrint.Print(sender: Tobject);
begin
setplace(nil);
QuickRep.print;
end;
procedure TPublicPrint.setplace(sender: Tobject);
var
i, j: integer;
Reg: TRegistry;
keyname, section: string;
begin
keyname := 'rep' + no;
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
section := '\Software\Gd\UserCustomSet\' + keyname;
if Reg.OpenKey(section, false) then
begin
for i := 0 to FQuickRep.ControlCount - 1 do
begin
if FQuickRep.Controls[i] is TQRBand then
begin
for j := 0 to (FQuickRep.Controls[i] as TQRBand).ControlCount - 1 do
if (FQuickRep.Controls[i] as TQRBand).Controls[j] is TObject then
if Reg.OpenKey(section + '\' + ((FQuickRep.Controls[i] as TQRBand).Controls[j] as TObject).Name, false) then
begin
((FQuickRep.Controls[i] as TQRBand).Controls[j] as TObject).Left := reg.ReadInteger('OldLeft') + reg.ReadInteger('Left');
((FQuickRep.Controls[i] as TQRBand).Controls[j] as TObject).top := reg.ReadInteger('OldTop') + reg.ReadInteger('Top');
if (FQuickRep.Controls[i] as TQRBand).Controls[j] is TQRLabel then
begin
((FQuickRep.Controls[i] as TQRBand).Controls[j] as TQRLabel).Font.Size := reg.ReadInteger('Zt');
if reg.Readbool('IsSave') then
((FQuickRep.Controls[i] as TQRBand).Controls[j] as TQRLabel).Caption := reg.ReadString('Displayname');
end;
if (FQuickRep.Controls[i] as TQRBand).Controls[j] is TQRDBText then
((FQuickRep.Controls[i] as TQRBand).Controls[j] as TQRDBText).Font.Size := reg.ReadInteger('Zt');
end;
end
else
if FQuickRep.Controls[i] is TQRChildBand then
begin
for j := 0 to (FQuickRep.Controls[i] as TQRChildBand).ControlCount - 1 do
begin
if Reg.OpenKey(section + '\' + ((FQuickRep.Controls[i] as TQRChildBand).Controls[j] as TObject).Name, false) then
begin
((FQuickRep.Controls[i] as TQRChildBand).Controls[j] as TObject).Left := reg.ReadInteger('OldLeft') + reg.ReadInteger('Left');
((FQuickRep.Controls[i] as TQRChildBand).Controls[j] as TObject).top := reg.ReadInteger('OldTop') + reg.ReadInteger('Top');
if (FQuickRep.Controls[i] as TQRChildBand).Controls[j] is TQRLabel then
begin
((FQuickRep.Controls[i] as TQRChildBand).Controls[j] as TQRLabel).Font.Size := reg.ReadInteger('Zt');
if reg.Readbool('IsSave') then
((FQuickRep.Controls[i] as TQRChildBand).Controls[j] as TQRLabel).Caption := reg.ReadString('Displayname');
end;
if (FQuickRep.Controls[i] as TQRChildBand).Controls[j] is TQRDBText then
((FQuickRep.Controls[i] as TQRChildBand).Controls[j] as TQRDBText).Font.Size := reg.ReadInteger('Zt');
end;
end;
end
else
if FQuickRep.Controls[i] is Tqrsubdetail then
begin
for j := 0 to (FQuickRep.Controls[i] as Tqrsubdetail).ControlCount - 1 do
begin
if Reg.OpenKey(section + '\' + ((FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] as TObject).Name, false) then
begin
((FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] as TObject).Left := reg.ReadInteger('OldLeft') + reg.ReadInteger('Left');
((FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] as TObject).top := reg.ReadInteger('OldTop') + reg.ReadInteger('Top');
if (FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] is TQRLabel then
begin
((FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] as TQRLabel).Font.Size := reg.ReadInteger('Zt');
if reg.Readbool('IsSave') then
((FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] as TQRLabel).Caption := reg.ReadString('Displayname');
end;
if (FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] is TQRDBText then
((FQuickRep.Controls[i] as Tqrsubdetail).Controls[j] as TQRDBText).Font.Size := reg.ReadInteger('Zt');
end;
end;
end
else
if FQuickRep.Controls[i] is TQRStringsBand then
begin
for j := 0 to (FQuickRep.Controls[i] as TQRStringsBand).ControlCount - 1 do
begin
if Reg.OpenKey(section + '\' + ((FQuickRep.Controls[i] as TQRStringsBand).Controls[j] as TObject).Name, false) then
begin
((FQuickRep.Controls[i] as TQRStringsBand).Controls[j] as TObject).Left := reg.ReadInteger('OldLeft') + reg.ReadInteger('Left');
((FQuickRep.Controls[i] as TQRStringsBand).Controls[j] as TObject).top := reg.ReadInteger('OldTop') + reg.ReadInteger('Top');
if (FQuickRep.Controls[i] as TQRStringsBand).Controls[j] is TQRLabel then
begin
((FQuickRep.Controls[i] as TQRStringsBand).Controls[j] as TQRLabel).Font.Size := reg.ReadInteger('Zt');
if reg.Readbool('IsSave') then
((FQuickRep.Controls[i] as TQRStringsBand).Controls[j] as TQRLabel).Caption := reg.ReadString('Displayname');
end;
if (FQuickRep.Controls[i] as TQRStringsBand).Controls[j] is TQRDBText then
((FQuickRep.Controls[i] as TQRStringsBand).Controls[j] as TQRDBText).Font.Size := reg.ReadInteger('Zt');
end;
end;
end
else
begin
if Reg.OpenKey(section + '\' + (FQuickRep.Controls[i] as TObject).Name, false) then
begin
(FQuickRep.Controls[i] as TObject).Left := reg.ReadInteger('OldLeft') + reg.ReadInteger('Left');
(FQuickRep.Controls[i] as TObject).top := reg.ReadInteger('OldTop') + reg.ReadInteger('Top');
if FQuickRep.Controls[i] is TQRLabel then
begin
(FQuickRep.Controls[i] as TQRLabel).Font.Size := reg.ReadInteger('Zt');
if reg.Readbool('IsSave') then
(FQuickRep.Controls[i] as TQRLabel).Caption := reg.ReadString('Displayname');
end;
if FQuickRep.Controls[i] is TQRDBText then
(FQuickRep.Controls[i] as TQRDBText).Font.Size := reg.ReadInteger('Zt');
end;
end;
end;
end;
end;
procedure TPublicPrint.SetQuickRep(const Value: TQuickrep);
begin
FQuickRep := Value;
end;
procedure TPublicPrint.Setup;
var
OldParent: TWinControl;
begin
OldParent := FQuickRep.parent;
FQuickRep.parent := FSetupForm.ScrollBox1;
Urepset.rep := FQuickRep;
FSetupForm.ShowModal;
FQuickRep.parent := OldParent;
end;
procedure Register;
begin
RegisterComponents('MA', [TPublicPrint]);
end;
procedure TPublicPrint.Setprinttype(const Value: TPrinttype);
begin
Fprinttype := Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -