Printers: Match Windows PageSetupDialog settings with the Unix dialog. Issue #33427, patch from AlexeyT.

git-svn-id: trunk@57517 -
This commit is contained in:
juha 2018-03-16 22:09:56 +00:00
parent dd8971ca15
commit 2791021ac9
2 changed files with 15 additions and 39 deletions

View File

@ -20,38 +20,6 @@ begin
end;
end;
function GetNumber(FromLeft: boolean; s:ansistring; aDefault: Integer): Integer;
var
i: Integer;
res: string;
begin
if FromLeft then
i := 1
else
i := Length(s);
Res := '';
while (i>0)and(i<=Length(s)) do
begin
if s[i] in ['0'..'9'] then begin
if Fromleft then
Res:=Res+S[i]
else
Res:=S[i]+Res;
end else begin
if Res<>'' then
break;
end;
if FromLeft then
Inc(i)
else
Dec(i);
end;
Result := StrToIntDef(Res, aDefault);
end;
{ TPrintDialog }
function TPrintDialog.DoExecute: Boolean;
@ -94,15 +62,15 @@ begin
// simple rules.
i := pos('-', Dlg.edRange.Text);
if i<>0 then begin
FromPage := GetNumber(False, copy(Dlg.edRange.Text, 1, i-1), FromPage);
ToPage := GetNumber(True, copy(Dlg.edRange.Text, i+1, 255), ToPage);
FromPage := StrToIntDef(Trim(Copy(Dlg.edRange.Text, 1, i-1)), FromPage);
ToPage := StrToIntDef(Trim(Copy(Dlg.edRange.Text, i+1, MaxInt)), ToPage);
if ToPage<FromPage then begin
i := ToPage;
ToPage := FromPage;
FromPage := i;
end;
end else begin
Self.FromPage := GetNumber(True, copy(Dlg.edRange.Text, i+1, 255), Self.FromPage);
Self.FromPage := StrToIntDef(Trim(Dlg.edRange.Text), Self.FromPage);
Self.ToPage := Self.FromPage;
end;
end;

View File

@ -95,7 +95,11 @@ begin
lCustData := 0;
Flags := PSD_MARGINS or PSD_ENABLEPAGESETUPHOOK;
hWndOwner := GetOwnerHandle(Self);
rtMargin := fMargins;
// TODO: check that no need to div by 1000 values below
rtMargin.Left := MarginLeft;
rtMargin.Top := MarginTop;
rtMargin.Right := MarginRight;
rtMargin.Bottom := MarginBottom;
PDev := TPrinterDevice(Printer.Printers.Objects[Printer.PrinterIndex]);
// Pdev.DevMode has the required size, just copy to the global memory
DeviceMode := GLobalAlloc(GHND, PDev.DevModeSize);
@ -125,10 +129,14 @@ begin
Result:=True;
if (Flags and PSD_INHUNDREDTHSOFMILLIMETERS)>0 then
fUnits := unMM
fUnits := pmMillimeters
else
fUnits := unInch;
fMargins := rtMargin;
fUnits := pmInches;
MarginLeft := rtMargin.Left;
MarginTop := rtMargin.Top;
MarginRight := rtMargin.Right;
MarginBottom := rtMargin.Bottom;
if lpp.hDevMode <> 0 then
begin