U
uncarman
Unregistered / Unconfirmed
GUEST, unregistred user!
编写了一个票据打印的函数如下
function TPrinterComm.PrintTicket(ticketCount: Integer): Integer;
var
dcHandle: HDC;
di: TDOCINFO;
pdi: PDOCINFO;
fontHandle: HFONT;
oldFontHandle: HGDIOBJ;
bRes: LongBool;
tm: TTextMetric;
iPosition,i: Integer;
begin
Result := 0;
dcHandle := CreateDC(nil, PChar(DRV_NAME_BAT500_FULLCUT), nil, nil);
pdi := @di;
ZeroMemory(pdi, SizeOf(TDOCINFO));
di.cbSize := sizeof(TDOCINFO);
di.lpszDocName := '食堂餐券';
StartDoc(dcHandle,di);
for i := 0 to ticketCount - 1do
// Iterate
begin
StartPage(dcHandle);
fontHandle := CreateFont(130,50, 0, 0, FW_BOLD, 0, 0,0,
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FW_DONTCARE or FW_DONTCARE, 'FontA DHDW');
oldFontHandle := SelectObject(dcHandle,fontHandle);
bRes := TextOut(dcHandle,0,90,'食堂餐券',12);
if not bRes then
begin
Result := -2;
Exit;
end;
GetTextMetrics(dcHandle,tm);
iPosition := tm.tmHeight + tm.tmExternalLeading + 90;
bRes := TextOut(dcHandle,180,iPosition,'8 元',4);
if not bRes then
begin
Result := -2;
Exit;
end;
EndPage(dcHandle);
end;
// for
EndDoc(dcHandle);
SelectObject(dcHandle,oldFontHandle);
DeleteDC(dcHandle);
end;
如何控制打印纸张大小和打印区域大小,以及打印方向,另外怎样打印图形,
请高手指点
function TPrinterComm.PrintTicket(ticketCount: Integer): Integer;
var
dcHandle: HDC;
di: TDOCINFO;
pdi: PDOCINFO;
fontHandle: HFONT;
oldFontHandle: HGDIOBJ;
bRes: LongBool;
tm: TTextMetric;
iPosition,i: Integer;
begin
Result := 0;
dcHandle := CreateDC(nil, PChar(DRV_NAME_BAT500_FULLCUT), nil, nil);
pdi := @di;
ZeroMemory(pdi, SizeOf(TDOCINFO));
di.cbSize := sizeof(TDOCINFO);
di.lpszDocName := '食堂餐券';
StartDoc(dcHandle,di);
for i := 0 to ticketCount - 1do
// Iterate
begin
StartPage(dcHandle);
fontHandle := CreateFont(130,50, 0, 0, FW_BOLD, 0, 0,0,
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FW_DONTCARE or FW_DONTCARE, 'FontA DHDW');
oldFontHandle := SelectObject(dcHandle,fontHandle);
bRes := TextOut(dcHandle,0,90,'食堂餐券',12);
if not bRes then
begin
Result := -2;
Exit;
end;
GetTextMetrics(dcHandle,tm);
iPosition := tm.tmHeight + tm.tmExternalLeading + 90;
bRes := TextOut(dcHandle,180,iPosition,'8 元',4);
if not bRes then
begin
Result := -2;
Exit;
end;
EndPage(dcHandle);
end;
// for
EndDoc(dcHandle);
SelectObject(dcHandle,oldFontHandle);
DeleteDC(dcHandle);
end;
如何控制打印纸张大小和打印区域大小,以及打印方向,另外怎样打印图形,
请高手指点