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
Using call prototype | Picture (32-bit systems) | Picture (64-bit systems) | |
---|---|---|---|
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.
The following example shows how to use the 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.
The following example shows how to create an anonymous delegate (without specifying a name for the delegate) and then use it with the 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
You can use this delegate with the PC_PRINTER_INFO_DOTNET API as follows:
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
Accessing native resources:
The PC_PRINTER_INFO is unable to return the underlying Hdc attribute for a printer connection on the .NET platform as the attribute is only available during a page-event. You can use the PC_PRINTER_INFO_DOTNET API, however, to access the native Hdc for the printer.
In the delegate, you can use the GetHdc() and the ReleaseHdc() methods on the graphics object. For example: