.版本 2
.子程序 _初始化, , , 当基于本类的对象被创建后,此方法会被自动调用
.局部变量 bpinout, GdiplusStartupInput
bpinout.GdiplusVersion = 1
API_GdiplusStartup (this.token, bpinout, 0)
.子程序 _销毁, , , 当基于本类的对象被销毁前,此方法会被自动调用
API_GdiplusShutdown (this.token)
.子程序 open, 逻辑型, 公开, 打开打印机
.参数 name, 文本型
.参数 pect, 整数型, 可空, 纸张方向: 1、纵向; 2、横向
.参数 paper, 整数型, 可空, 默认A4 > 纸张: 8、A3纸; 9、A4纸;11、A5纸 ......
.如果真 (document (name, this))
this.name = name
' +44 横纵方向 1,2
' +46 纸张类型
' +48 纸张高度
' +50 纸张宽带
' +54 打印份数
' +58 分辨率
.如果真 (pect > 0)
WriteShort (this.memory + 44, pect)
.如果真结束
.如果真 (paper > 0)
WriteShort (this.memory + 46, paper)
.如果真结束
.如果真结束
返回 (this.memory ≠ 0)
.子程序 readys, 逻辑型, 公开, 准备打印->建立文档
.参数 name, 文本型, , 文档名称
.参数 count, 整数型, 可空, 打印页数
.参数 num, 整数型, 可空, 每页打印多少张
.参数 output, 文本型, 可空, 输出文件名
.局部变量 document, DOCINFO
.如果真 (this.memory ≠ 0)
.如果真 (num > 0)
WriteShort (this.memory + 54, num) ' 每页打印多少张
.如果真结束
this.count = count
this.device = API_CreateDC (0, this.name, 0, this.memory) ' 获取设备句柄
.如果真 (this.device ≠ 0)
document.cbSize = 12
document.lpszDocName = name
document.lpszOutput = output
返回 (API_StartDoc (this.device, document) > 0)
.如果真结束
.如果真结束
返回 (假)
.子程序 print, 逻辑型, 公开, 打印
.参数 draw, 子程序指针, , 绘制指针: ([int] context, [int] index, [int] custom)
.参数 margin, Margin, 可空, 边距偏移: (单位: 毫米)
.参数 custom, 整数型, 可空, 自定义参数
.局部变量 response, response_this
.局部变量 disponse, draw_this
.局部变量 i, 整数型
this.draw = GetPiont (draw)
.如果真 (this.memory ≠ 0 且 this.device ≠ 0)
response.memory = new (4096) ' 申请一个绘画空间
.如果真 (response.memory ≠ 0)
disponse.device = this.device ' 设备句柄
.如果真 (scene (margin, disponse, response)) ' 创建一个屏幕画布
toMemory (response.memory, disponse, LocalSize (disponse)) ' 拷贝到内存
.计次循环首 (this.count, i)
API_GdipGraphicsClear (response.graphics, -1)
API_Call ({ 85, 139, 236, 255, 117, 20, 255, 117, 16, 255, 117, 12, 255, 85, 8, 201, 194, 16, 0 }, this.draw, response.memory, i, custom)
API_BitBlt (this.device, response.rc.x, response.rc.y, response.rc.width, response.rc.height, response.hDc, 0, 0, 13369376) ' 把画布复制到打印机
API_EndPage (this.device) ' 画布准备完成, 发送至打印机
.计次循环尾 ()
unscene (response) ' 释放场景画布
.如果真结束
delete (response.memory)
.如果真结束
.如果真结束
返回 (i > 0)
.子程序 finish, 逻辑型, 公开, 完成打印,结束
.如果真 (this.device ≠ 0)
API_EndDoc (this.device)
API_DeleteDC (this.device)
.如果真结束
.如果真 (this.memory ≠ 0)
delete (this.memory)
.如果真结束
连续赋值 (0, this.memory, this.device)
返回 (真)