以前做的发票打印程序都用PRINTER。定位还可以,前几天看了一个商业程序。发票的格式可以自己建立、设定的。觉得不错。
请问DELPHI里用哪种报表控件干这个比较不错?
定位准的。谢谢各位了!
请问DELPHI里用哪种报表控件干这个比较不错?
定位准的。谢谢各位了!
解决方案 »
- Delphi如何根据选择的下拉菜单不一样,而读取SQL数据库相应的记录
- 使用xmldom解析XML时,无法用selectNodes找到对应的节点。
- 为什么panel上画图会被自动刷新掉??什么容器控件 不会被刷新?
- 如何取得dbgrideh的footer之sum所求得的值,急
- 关于delphi的问题,老是出现找不到字段
- Excel文件如何实现更新sql 数据库?高手请指点
- 在线等待,解决送分
- DELPH程序中出现的问题
- 1。win98做拨入2。如果机器1和机器2通过拨号相连,机器1如何访问机器2上的sql server?
- 谁有delphi5的wordapplication、worddocument等属性、方法说明,有例程最好
- 在线求救!!!!帮帮我呀!
- 网络编程请大家关注!!!在线,(急!!!)
uses printers, Variants, Graphics, SysUtils, Controls, Windows;function GetOffSetX: Integer;
function GetOffSetY: Integer;
function VPointsPerInch: Integer;
function HPointsPerInch: Integer;
function XPointToMm(Pos: Integer): Extended;
function YPointToMm(Pos: Integer): Extended;
function InchToMm(Length: Extended): Extended;
function MmToInch(Length: Extended): Extended;
function CharHeight: Word;
function xMmtoPoint(mm:Extended):extended;overload;
function yMmToPoint(mm:Extended):Extended;overload;
function xMmtoPoint(mm:integer):extended;overload;
function yMmToPoint(mm:integer):Extended;overload;
procedure PrintToPaper(x,y:Extended;text:string);overload;
procedure PrintToPaper(x,y:integer;text:string);overload;
procedure PrintToPaperV(x,y:Extended;text:string);overload;
procedure PrintToPaperV(x,y:integer;text:string);overload;implementation
///取得纸张的横向偏移量-单位:点
function GetOffSetX: Integer;
begin
Result := GetDeviceCaps(Printer.Handle, PhysicalOffSetX);
end;
//取得纸张的纵向偏移量-单位:点function GetOffSetY: Integer;
begin
Result := GetDeviceCaps(Printer.Handle, PhysicalOffSetY);
end;//取得纵向方向每英寸打印机的光栅数function VPointsPerInch: Integer;
begin
Result := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
end;
//取得水平方向每英寸打印机的点数function HPointsPerInch: Integer;
begin
Result := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
end;//横向点单位转换为毫米单位function XPointToMm(Pos: Integer): Extended;
begin
Result := Pos * 25.4 / HPointsPerInch;
end;//纵向点单位转换为毫米单位function YPointToMm(Pos: Integer): Extended;
begin
Result := Pos * 25.4 / VPointsPerInch;
end;//英寸单位转换为毫米单位function InchToMm(Length: Extended): Extended;
begin
Result := Length * 25.4;
end;//毫米单位转换为英寸单位function MmToInch(Length: Extended): Extended;
begin
Result := Length / 25.4;
end;
///字体高度////////////////////////////////////////////////////////////////
function CharHeight: Word;
var
Metrics: TTextMetric;
begin
GetTextMetrics(Printer.Canvas.Handle, Metrics);
Result := Metrics.tmHeight;
end;//X毫米/打印点////////////////////////////////////////////////////////////////
function xMmtoPoint(mm:Extended):extended;
begin
Result :=mm*HPointsPerInch/25.4;
end;//Y毫米/打印点/////////////////////////////////////////////////
function yMmToPoint(mm:Extended):Extended;
begin
Result :=mm*VPointsPerInch/25.4;
end;
//X毫米/打印点////////////////////////////////////////////////////////////////
function xMmtoPoint(mm:integer):extended;
begin
Result :=mm*HPointsPerInch/25.4;
end;//Y毫米/打印点/////////////////////////////////////////////////
function yMmToPoint(mm:integer):Extended;
begin
Result :=mm*VPointsPerInch/25.4;
end;
procedure PrintToPaper(x,y:Extended;text:string);
var
ax,ay:integer;
begin
ax:=Round(xMmtoPoint(x))-GetOffSetX ;
ay:=Round(yMmToPoint(y))-GetOffSetY ;
Printer.Canvas.TextOut(ax,ay,text);
end;
procedure PrintToPaper(x,y:integer;text:string);
var
ax,ay:integer;
begin
ax:=Round(xMmtoPoint(x))-GetOffSetX ;
ay:=Round(yMmToPoint(y))-GetOffSetY ;
Printer.Canvas.TextOut(ax,ay,text);
end;procedure PrintToPaperV(x,y:Extended;text:string);
var
ax,ay:integer;
begin
ax:=Round(xMmtoPoint(x))-GetOffSetY ;
ay:=Round(yMmToPoint(y))+GetOffSetX ;
Printer.Canvas.TextOut(ax,ay,text);
end;
procedure PrintToPaperV(x,y:integer;text:string);
var
ax,ay:integer;
begin
ax:=Round(xMmtoPoint(x))-GetOffSetY ;
ay:=Round(yMmToPoint(y))+GetOffSetX ;
Printer.Canvas.TextOut(ax,ay,text);
end;end.
你的方法不错
可 打印预览怎么搞啊!
还有要是连续打印多页那?(代打印预览)
//想得分去
http://expert.csdn.net/Expert/TopicView1.asp?id=2077304