有关打印的问题,请各位高手帮忙! |
尚未結案
|
somin
一般會員 發表:4 回覆:6 積分:2 註冊:2002-11-28 發送簡訊給我 |
在不调用WINDOWS自带的打印机制,怎么写代码控制LPT并行口,由并行口打印东西,并且在打印的时候要打印出不同的字体和字体大小。
ffont:=tfont.Create;
ffont.Charset:=GB2312_CHARSET;
ffont.Name:='Arial';
ffont.Size:=10;
printer.Canvas.Font:=ffont;
assignfile(prntext);
if filehandle>0 then
filewrite(filehandle, prntext[1], length(prntext))
else
showmessage('');
fileclose(filehandle);
这个可以控制打印,但是不能改变字体。
有那位有SPCOMM来设置LPT并行口的代码,请帮忙。先谢谢了!!!
hNewCommFile := CreateFile( 'LPT1',
GENERIC_READ OR GENERIC_WRITE,
0, {not shared}
nil, {no security ??}
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL OR FILE_FLAG_OVERLAPPED,
0 {template} ); if hNewCommFile = INVALID_HANDLE_VALUE then
raise ECommsError.Create( 'Error opening serial port' ); // Is this a valid comm handle?
if GetFileType( hNewCommFile ) <> FILE_TYPE_CHAR then
begin
CloseHandle( hNewCommFile );
raise ECommsError.Create( 'File handle is not a comm handle ' );
end; if not SetupComm( hNewCommFile, 4096, 4096 ) then
begin
CloseHandle( hCommFile );
raise ECommsError.Create( 'Cannot setup comm buffer' )
end;
我每次调试在上面代码红色的部门就跳出,请各位高手帮忙! 發表人 - somin 於 2005/09/21 09:57:50
|
somin
一般會員 發表:4 回覆:6 積分:2 註冊:2002-11-28 發送簡訊給我 |
怎么没有人帮助我呀,各位大老,帮我想想呀!
引言: 在不调用WINDOWS自带的打印机制,怎么写代码控制LPT并行口,由并行口打印东西,并且在打印的时候要打印出不同的字体和字体大小。 ffont:=tfont.Create; ffont.Charset:=GB2312_CHARSET; ffont.Name:='Arial'; ffont.Size:=10; printer.Canvas.Font:=ffont; assignfile(prntext); if filehandle>0 then filewrite(filehandle, prntext[1], length(prntext)) else showmessage(''); fileclose(filehandle); 这个可以控制打印,但是不能改变字体。 有那位有SPCOMM来设置LPT并行口的代码,请帮忙。先谢谢了!!! hNewCommFile := CreateFile( 'LPT1', GENERIC_READ OR GENERIC_WRITE, 0, {not shared} nil, {no security ??} OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL OR FILE_FLAG_OVERLAPPED, 0 {template} ); if hNewCommFile = INVALID_HANDLE_VALUE then raise ECommsError.Create( 'Error opening serial port' ); // Is this a valid comm handle? if GetFileType( hNewCommFile ) <> FILE_TYPE_CHAR then begin CloseHandle( hNewCommFile ); raise ECommsError.Create( 'File handle is not a comm handle ' ); end; if not SetupComm( hNewCommFile, 4096, 4096 ) then begin CloseHandle( hCommFile ); raise ECommsError.Create( 'Cannot setup comm buffer' ) end; 我每次调试在上面代码红色的部门就跳出,请各位高手帮忙! 發表人 - somin 於 2005/09/21 09:57:50 |
somin
一般會員 發表:4 回覆:6 積分:2 註冊:2002-11-28 發送簡訊給我 |
procedure TForm1.Button4Click(Sender: TObject);
var line:integer;
prntext:system.text;
temp:string;
fFont: TFont;
begin
//inherited;
inicom;
// ResetPrinter;
try
// temp:=m_bill.Lines.Text;
fFont :=TFont.Create;
fFont.Charset :=ANSI_CHARSET;
fFont.Name :='Arial';
fFont.Size :=10;
printer.canvas.font :=fFont;
assignfile(prntext,sCom);
rewrite(prntext);
//writeln(prntext,temp);
for line:=0 to M_Bill.lines.count-1 do
writeln(prntext,M_Bill.lines[line]);//把MEMO的内容写到打印机对象
system.close(prntext);
fFont.Free;
Except
fFont.Free;
end;
end;
为什么字体定义没有效果,不起作用了,请各位帮忙! 發表人 - somin 於 2005/09/26 17:21:29
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |