• R/O
  • SSH
  • HTTPS

apollo: Commit


Commit MetaInfo

Revision557 (tree)
Time2007-09-03 15:30:24
Authormoriq

Log Message

printer_index の挙動がおかしいので SetPrinter をやめる。[ap-dev:2219]

added Printer#paper_size. [ap-dev:2219]

Change Summary

Incremental Difference

--- apollo/trunk/src/u/uPrinter.pas (revision 556)
+++ apollo/trunk/src/u/uPrinter.pas (revision 557)
@@ -22,6 +22,7 @@
2222 interface
2323
2424 uses
25+ Windows,
2526 {$IFDEF VCL}
2627 Printers,
2728 {$ELSE}
@@ -52,15 +53,6 @@
5253 end;
5354
5455 {$IFDEF VCL}
55-procedure SetPrinter;
56-var
57- Device, Driver, Port: array[0..512] of Char;
58- hDev: THandle;
59-begin
60- Printer.GetPrinter(Device, Driver, Port, hDev);
61- Printer.SetPrinter(Device, Driver, Port, 0);
62-end;
63-
6456 function Printer_get_printer_index(This: Tvalue): Tvalue; cdecl;
6557 var
6658 real: TPrinter;
@@ -67,7 +59,6 @@
6759 begin
6860 real := ap_data_get_struct(This);
6961 result := ap_Fixnum(real.PrinterIndex);
70- SetPrinter;
7162 end;
7263
7364 function Printer_set_printer_index(This, v: Tvalue): Tvalue; cdecl;
@@ -166,6 +157,38 @@
166157 TPrinter(ap_data_get_struct(This)).Orientation := TPrinterOrientation(dl_Integer(v));
167158 end;
168159
160+function Printer_set_paper_size(This,v: Tvalue): Tvalue; cdecl;
161+var
162+ DrvName, PrtName, PortName : array[0..127] of Char;
163+ DeviceMode : THandle;
164+ PDevMode : ^TDevMode;
165+begin
166+ result := v;
167+ with Printer do begin
168+ GetPrinter(DrvName, PrtName, PortName, DeviceMode);
169+ PDevMode := GlobalLock(DeviceMode);
170+ PDevMode^.dmFields := PDevMode^.dmFields or dm_PaperSize;
171+ PDevMode^.dmPaperSize := dl_Integer(v); // DMPAPER_B4;
172+ GlobalUnlock(DeviceMode);
173+ SetPrinter(DrvName, PrtName, PortName, DeviceMode);
174+ end;
175+end;
176+
177+function Printer_get_paper_size(This: Tvalue): Tvalue; cdecl;
178+var
179+ DrvName, PrtName, PortName : array[0..127] of Char;
180+ DeviceMode : THandle;
181+ PDevMode : ^TDevMode;
182+begin
183+ with Printer do begin
184+ GetPrinter(DrvName, PrtName, PortName, DeviceMode);
185+ PDevMode := GlobalLock(DeviceMode);
186+ result := ap_Integer(PDevMode^.dmPaperSize);
187+ GlobalUnlock(DeviceMode);
188+ SetPrinter(DrvName, PrtName, PortName, DeviceMode);
189+ end;
190+end;
191+
169192 function Printer_instance(This: Tvalue): Tvalue; cdecl;
170193 begin
171194 result := vPrinter;
@@ -234,6 +257,9 @@
234257 DefineAttrSet(cPrinter, 'copies', Printer_set_copies);
235258 DefineAttrSet(cPrinter, 'orientation', Printer_set_orientation);
236259
260+ DefineAttrSet(cPrinter, 'paper_size', Printer_set_paper_size);
261+ DefineAttrGet(cPrinter, 'paper_size', Printer_get_paper_size);
262+
237263 OutputConstSetType(mPhi, TypeInfo(TPrinterCapability));
238264 OutputConstSetType(mPhi, TypeInfo(TPrinterOrientation));
239265
Show on old repository browser