如何在WINDOWS2000下快速打印发票!
解决方案 »
- 如何用TBlobStream保存imange字段类型的rar格式的大压缩文件?
- TwindowsMediaplayer控件,playlist的使用问题
- ****************兰州地区高薪城聘DElphi程序员(2000~5000/月+提成)****************
- 一个指针的问题
- VC写的DLL的一个函数返回类型是char**,在Delphi下如何使用?
- Delphi Stringlist Delimiter如何区分TAB和空格
- 那各位有谁知道TComm控件哪里有的下载,要么谁有请发给我一个
- 这条语句怎么写?
- ListView的困惑 请大虾赐教
- 各位程序员大虾:做个调查,大家都用什么输入法。
- 求,dbexpress 中用sqlquery 怎么取得recordcount
- 请问怎么将JPG图片缩小为BMP图片?
function CharHeight: Word;
var
Metrics:TTextMetric;
begin
GetTextMetrics(Printer.Canvas.Handle,Metrics);
Result:=Metrics.tmHeight;
end;function AvgCharWidth: Word;
var
Metrics:TTextMetric;
begin
GetTextMetrics(Printer.Canvas.Handle,Metrics);
Result:=Metrics.tmAveCharWidth;
end;function GetPhicalPaper: TPoint;
var
PageSize:TPoint;
begin
Escape(Printer.Handle, GETPHYSPAGESIZE, 0,nil,@PageSize);
Result := PageSize;
end;function PaperLogicSize: TPoint;
var
APoint:TPoint;
begin
APoint.X:=Printer.PageWidth;
APoint.Y:=Printer.PageHeight;
Result:=APoint;
end;function HVLogincRatio: Extended;
var
AP:TPoint;
begin
Ap:=PaperLogicSize;
Result:=Ap.y/Ap.X;
end;function GetOffSetX:Integer;
begin
Result:=GetDeviceCaps(Printer.Handle,PhysicalOffSetX);
end;function GetOffSetY:Integer;
begin
Result:=GetDeviceCaps(Printer.Handle,PhysicalOffSetY);
end;function MmToInch(Length: Extended): Extended;
begin
Result:=Length/25.4;
end;function InchToMm(Length:Extended):Extended;
begin
Result:=Length*25.4;
end;function HPointsPerInch:Integer;
begin
Result:=GetDeviceCaps(Printer.Handle,LOGPIXELSX);
end;function VPointsPerInch:Integer;
begin
Result:=GetDeviceCaps(Printer.Handle,LOGPIXELSY)
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;procedure SetPaperHeight(Value:integer);
var
Device:array[0..255] of char;
Driver:array[0..255] of char;
Port:array[0..255] of char;
hDMode:THandle;
PDMode:PDEVMODE;
begin
// if Value<127 then Value:=127;
// if Value > 432 then Value := 432;
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
pDMode:=GlobalLock(hDMode);
if pDMode<>nil then
begin
pDMode^.dmFields :=pDMode^.dmFields or DM_PAPERSIZE or DM_PAPERLENGTH;
// pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperSize :=0;
pDMode^.dmPaperLength := Value * 10;
pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
pDMode^.dmDefaultSource := DMBIN_MANUAL;
GlobalUnlock(hDMode);
end;
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;Procedure SetPaperWidth(Value:integer);
var
Device:array[0..255] of char;
Driver:array[0..255] of char;
Port:array[0..255] of char;
hDMode:THandle;
PDMode:PDEVMODE;
begin
// if Value < 76 then Value := 76;
// if Value > 216 then Value := 216;
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
pDMode^.dmFields := pDMode^.dmFields or DM_PAPERSIZE or DM_PAPERWIDTH;
// pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperSize :=0;
pDMode^.dmPaperWidth := Value * 10;
pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
pDMode^.dmDefaultSource := DMBIN_MANUAL;
GlobalUnlock(hDMode);
end;
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;procedure PrintText(X, Y: Extended; Txt,FontName:String;FontSize:Integer);
var
Px,Py:Integer;
OffSetX, OffSetY: Integer;
begin
OffSetX:=0;
OffSetY:=0;
X := X + OffSetX;
Y := Y + OffSetY;
Px := Round(Round(X * HPointsPerInch * 10000/25.4) / 10000);
Py := Round(Round(Y * VPointsPerInch * 10000/25.4) / 10000);
Py := Py - GetOffSetY;
Px := Px + 2 * AvgCharWidth;
Printer.Canvas.Font.Name := FontName;
Printer.Canvas.Font.Size := FontSize;
Printer.Canvas.TextOut(Px, Py, Txt);
end;
//*******************************************************************************
//使用时先调用
// SetPaperHeight(65);
// SetPaperWidth(175);
//设置发票的高度和宽度(单位:毫米)
// Printer.BeginDoc;
// PrintText(X坐标,Y坐标,‘要打印的字符!’,'字体',字体大小);
// Printer.EndDoc;