call "PC_PRINTER_INFO_DOTNET" using by reference cblt-pi-printer-handle by value cblt-printer-info-delegate by value user-object returning status-code end-call
呼び出しプロトタイプの使用 | PIC (32 ビット システム) | PIC (64 ビット システム) | |
---|---|---|---|
printer-handle | cblt-pi-printer-handle | pic x(4) comp-5 | pic x(8) comp-5 |
delegate | cblt-printer-info-delegate | see delegate-id above | see delegate-id above |
user-object | object | object | object |
delegate-id PrinterInfoDelegate. procedure division using by value gr as type Graphics by value pb as type Rectangle by value ps as type PageSettings by value uo as object . end delegate.
次の例に、PC_PRINTER_INFO_DOTNET API を使用する方法を示します。
$set iltarget"x86" $set ilref"System.Drawing" $set ilusing"System.Drawing". $set ilusing"System.Drawing.Printing". program-id. pcid. special-names. call-convention 74 is winapi. working-storage section. copy "cbltypes.cpy". 01. 03 document-title. 05 title-len pic x(2) comp-5. 05 title-text pic x(20). 03 font-family. 05 font-family-namelen pic x(2) comp-5 value 80. 05 font-family-name pic x(80). 03 abort pic x(4) comp-5 value 1. 03 ctrl pic x(4) comp-5 value 2. 03 flags pic x(4) comp-5 value 1. 03 handle pic x(4) comp-5. 01 status-code cblt-os-size value zeroes. procedure division. move 30 to title-len move "PC_PRINTER_INFO_DOTNET Example" to title-text call "PC_PRINTER_OPEN" using by reference handle by reference document-title by value flags by value 0 returning status-code end-call if status-code not equal 0 exhibit named status-code stop run end-if declare pinfo-delegate as type PrinterInfoDelegate set pinfo-delegate to delegate(gr as type Graphics, pb as type Rectangle, ps as type PageSettings uo as object ) *> create an Eclipse the side of the page declare customColor = type Color::FromArgb(50, type Color::Blue) declare shadowBrush = new SolidBrush(customColor) invoke gr::FillEllipse(shadowBrush, pb) declare bigText as string = uo as string declare drawFormat = new StringFormat set drawFormat::Alignment to type StringAlignment::Center set drawFormat::LineAlignment to type StringAlignment::Center invoke gr::DrawString(bigText, new Font("Courier New", 24), new SolidBrush(type Color::Red), pb, drawFormat) end-delegate declare nullObject as object = null call "PC_PRINTER_INFO_DOTNET" using by reference handle by value pinfo-delegate by value "Big Red text in the middle" returning status-code end-call if status-code not equal 0 exhibit named status-code end-if call "PC_PRINTER_CLOSE" using by reference handle returning status-code end-call if status-code not equal 0 exhibit named status-code stop run end-if goback. end program. delegate-id PrinterInfoDelegate. procedure division using by value gr as type Graphics by value pb as type Rectangle by value ps as type PageSettings by value uo as object . end delegate.
次の例に、(デリゲートの名前を指定せずに) 匿名デリゲートを作成して PC_PRINTER_INFO_DOTNET API でそれを使用する方法を示します。
declare pinfo-delegate as type PrinterInfoDelegate set pinfo-delegate to delegate(gr as type Graphics, pb as type Rectangle, ps as type PageSettings uo as object) display "DpiX = " gr::DpiX display "DpiY = " gr::DpiY display "Page Boundary : " pb display "Page Settings : " ps end-delegate
次のように、このデリゲートは PC_PRINTER_INFO_DOTNET API で使用できます。
call "PC_PRINTER_INFO_DOTNET" using by reference handle by value pinfo-delegate by value self *> user-object is the program itself *> so you can do a pinfo-delegate to the entry-point end-call
ネイティブ リソースへのアクセス:
PC_PRINTER_INFO は、属性がページイベント時にのみ有効であるため、.NET プラットフォーム上のプリンター接続の基本的な Hdc 属性を返すことができません。ただし、PC_PRINTER_INFO_DOTNET API を使用すると、プリンターのネイティブ Hdc にアクセスできます。
デリゲートでは、グラフィック オブジェクトの GetHdc() メソッドおよび ReleaseHdc() メソッドを使用できます。次に例を示します。