BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PC freeze: .. Almost hopeless

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
E. P.
Guest





PostPosted: Sun Oct 19, 2003 8:28 am    Post subject: PC freeze: .. Almost hopeless Reply with quote



Hi
I know it is a long shot, but maybe someone can help.
I have a Delhi 5 App, running on Win98 2nd edition at the Customer
site. Occasionally, apparantly after running the code below, the PC
freezes, dows not respong to any command etc.
Is there anything suspicious in the code below?
Or is the Print Spool in Win98 itself that may be somewhat defective
on that particular PC? If so, can anything be checked and/or replace in
the OS to get rid of that?
Thanks for any help.
E.P.

procedure opendrawer;
var
oldFont:TFont;
PrintText: TextFile;
n:smallint;
begin
AssignPrn(PrintText);
OLDFONT:=Tfont.Create;
oldFont.Assign(Printer.Canvas.Font);
Rewrite(PrintText);
try
with Printer.Canvas do begin
Font.Size:=10;
Font.Name:='control';
write(PrintText,'A');
end;
finally
CloseFile(PrintText);
Printer.Canvas.Font.size:=oldFont.size;
Printer.Canvas.Font.name:=oldFont.name;
oldfont.free;
end;
end;


Back to top
Peter Below (TeamB)
Guest





PostPosted: Sun Oct 19, 2003 11:09 am    Post subject: Re: PC freeze: .. Almost hopeless Reply with quote



In article <3f922e58$1 (AT) newsgroups (DOT) borland.com>, E. P. wrote:
Quote:
I know it is a long shot, but maybe someone can help.
I have a Delhi 5 App, running on Win98 2nd edition at the Customer
site. Occasionally, apparantly after running the code below, the PC
freezes, dows not respong to any command etc.
Is there anything suspicious in the code below?

Yes, definitely.

Quote:
Or is the Print Spool in Win98 itself that may be somewhat defective
on that particular PC? If so, can anything be checked and/or replace in
the OS to get rid of that?
Thanks for any help.
E.P.

procedure opendrawer;
var
oldFont:TFont;
PrintText: TextFile;
n:smallint;
begin
AssignPrn(PrintText);
OLDFONT:=Tfont.Create;
oldFont.Assign(Printer.Canvas.Font);

You don't need to save the old printer font. And at the place your are
doing it the Printer.Canvas is not valid yet, since Printer.beginDoc has
not be called yet. It is the Rewrite call that does that.

Quote:
Rewrite(PrintText);
try
with Printer.Canvas do begin
Font.Size:=10;
Font.Name:='control';
write(PrintText,'A');
end;
finally
CloseFile(PrintText);
Printer.Canvas.Font.size:=oldFont.size;

Here comes the suspicious bit. CloseFile on a file created via AssignPrn
calls Printer.EndDoc, and after that the Printer.Canvas is no longer
valid. But as said above there is no need to save and restore the
printer.canvas.font

Quote:
Printer.Canvas.Font.name:=oldFont.name;
oldfont.free;
end;
end;


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Mike Lischke
Guest





PostPosted: Sun Oct 19, 2003 7:58 pm    Post subject: Re: PC freeze: .. Almost hopeless Reply with quote



E. P. wrote:

Quote:
a) if I want to set a font , for example, the sequence should be
BeginDoc;
Printer.Canvas.Font.Size:=10;
not viceversa?. i.e. before the BeginDoc call, Printer.Canvas is not
available?

Correct. The canvas is created first when you call BeginDoc.

Quote:
b) I do not need to save and restore fonts since the BeginDoc.. EndDoc
pair automatically restores the old fonts?

Correct too. Since the canvas is recreated each time there is no sense to restore the old font (the canvas gets default values).

Mike
--
www.delphi-gems.com
www.delphi-unicode.net
www.lischke-online.de

Back to top
E. P.
Guest





PostPosted: Sun Oct 19, 2003 8:50 pm    Post subject: Re: PC freeze: .. Almost hopeless Reply with quote

Thanks Peter.
Are you saying then:
a) if I want to set a font , for example, the sequence should be
BeginDoc;
Printer.Canvas.Font.Size:=10;
not viceversa?. i.e. before the BeginDoc call, Printer.Canvas is not
available?
b) I do not need to save and restore fonts since the BeginDoc.. EndDoc
pair automatically restores the old fonts?
Thanks again very much.

"Peter Below (TeamB)" <100113.1101 (AT) compuXXserve (DOT) com> wrote

Quote:
In article <3f922e58$1 (AT) newsgroups (DOT) borland.com>, E. P. wrote:
I know it is a long shot, but maybe someone can help.
I have a Delhi 5 App, running on Win98 2nd edition at the Customer
site. Occasionally, apparantly after running the code below, the PC
freezes, dows not respong to any command etc.
Is there anything suspicious in the code below?

Yes, definitely.

Or is the Print Spool in Win98 itself that may be somewhat defective
on that particular PC? If so, can anything be checked and/or replace in
the OS to get rid of that?
Thanks for any help.
E.P.

procedure opendrawer;
var
oldFont:TFont;
PrintText: TextFile;
n:smallint;
begin
AssignPrn(PrintText);
OLDFONT:=Tfont.Create;
oldFont.Assign(Printer.Canvas.Font);

You don't need to save the old printer font. And at the place your are
doing it the Printer.Canvas is not valid yet, since Printer.beginDoc has
not be called yet. It is the Rewrite call that does that.

Rewrite(PrintText);
try
with Printer.Canvas do begin
Font.Size:=10;
Font.Name:='control';
write(PrintText,'A');
end;
finally
CloseFile(PrintText);
Printer.Canvas.Font.size:=oldFont.size;

Here comes the suspicious bit. CloseFile on a file created via AssignPrn
calls Printer.EndDoc, and after that the Printer.Canvas is no longer
valid. But as said above there is no need to save and restore the
printer.canvas.font

Printer.Canvas.Font.name:=oldFont.name;
oldfont.free;
end;
end;


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.