print Cancel的问题

chenlq 2000-01-19 10:22:00
我在想要获得打印机的分辨率时,必须使用Printer.BeginDoc,是这样的吗?,因我这样作了以后在使用Printer.Cancel,在Local的打印机没有问题,只不过需要有多的一次初始化打印机罢了?但现在我使用网络打印机printer.Cancel不能取消打印任务这样的话,我必须打出一页白纸,请教诸位大侠这是为什么?我想要获得打印机的分辨率时,该如何处理?多谢!多谢!
...全文
288 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenlq 2000-01-21
  • 打赏
  • 举报
回复
以上回答不能解决问题!
barton 2000-01-20
  • 打赏
  • 举报
回复
我一直用smallbridge的方法好象没有问题呀?
smallBridge 2000-01-19
  • 打赏
  • 举报
回复
uses
printers, ...

procedure ...
var
h,v:integer;
begin
//水平分辨率
h := GetDeviceCaps(printer.Handle,LOGPIXELSX);
//垂直分辨率
v := GetDeviceCaps(printer.Handle,LOGPIXELSY);
end;
光明山人 2000-01-19
  • 打赏
  • 举报
回复
都错了,
TForm.Print需要BeginDoc;
Printer的DC不能得到,可以用Printer.Canvas.Handle。

正确的方法是:

procedure GetPrinterReso(
const PrinterName: string; // 打印机名
var Width, Height: Integer // 返回的分辨率
);
var
OldPrinterIndex: Integer;
begin
with Printer do
begin
OldPrinterIndex := PrinterIndex; // 保存原打印机索引
PrinterIndex := IndexOf( PrinterName ); // 用新的
Width := PageWidth;
Height := PageHeight;
PrinterIndex := OldPrinterIndex; // 恢复
end;
end;

这个例子没有错误检查,你自己加上。
kxy 2000-01-19
  • 打赏
  • 举报
回复
uses printer;

GetDeviceCaps(Printer.DC, LOGPIXELSX) 可以取得 dpi
huzi 2000-01-19
  • 打赏
  • 举报
回复
你可以看一看 forms.pas中 print 方法,其中有如何使用打印的内容。
在那里面,把打印机看成一个图形设备,自然包含有分辨率等信息。应该不用
Printer.BeginDoc。
kxy 2000-01-19
  • 打赏
  • 举报
回复
The GetDeviceCaps function retrieves device-specific information about a specified device.

int GetDeviceCaps(

HDC hdc, // device-context handle
int nIndex // index of capability to query
);

5,387

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧