Solved

API:  DrawText() problem

Posted on 2000-03-23
9
1,028 Views
Last Modified: 2013-12-03
When using the API DrawText() function for text output
                     
  DrawText(AHandle, '543210', -1, ADrawRect, DT_RIGHT or DTVCenter or DT_SingleLine)

on some printers (mainly newer HP drivers) the last digit is missing in printout. On other printers everything works just fine. The                 DrawRect is much wider than the string. Putting an additional space behind the last digit always solves the problem.

The original Windows HP Laserjet Series II driver never shows this behaviour.

Does anybody know the problem?

Thanks a lot, Roadrunner
(I have asked this Q before in the Delphi-Area)
0
Comment
Question by:Roadrunner100598
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 12

Expert Comment

by:pjknibbs
Comment Utility
I think you've said everything you need to say with "newer HP drivers"--HP can't write printer drivers to save their lives. Although I haven't seen this particular problem, I'd suggest passing the actual length of the string to DrawText() instead of -1 and see if that fixes it.
0
 
LVL 3

Expert Comment

by:MDarling
Comment Utility
Have you tried using DrawText with DT_CALCRECT (to get the rectangle ADrawRect), so that you can use it in the
Drawing call to DrawRect?

regards,
Mike.
0
 
LVL 1

Author Comment

by:Roadrunner100598
Comment Utility
To MDarling:
I normally use DT_CALCRECT first.
I even tried DT_CALCRECT, then added some pixels to Rect.Right... no use.
0
 
LVL 3

Expert Comment

by:MDarling
Comment Utility
Fair enough - i have a very new cheap HP deskjet at home - do you want to give me some sample code to try on it?

regards,
Mike.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Accepted Solution

by:
pjknibbs earned 150 total points
Comment Utility
Roadrunner: Did you try my suggestion? The other possibility is to specify DT_NOCLIP so the idiot printer driver doesn't try to clip out the last character.
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
'543210' should be "543210". I suppose it is just a typo.
0
 
LVL 1

Author Comment

by:Roadrunner100598
Comment Utility
to Pjknibbs:
The turn around cycle for testing is a bit long - all my computers do not show the problem, so I have to run all tests on a customers PC via PC-anywhere etc., so please be patient. DT_NOCLIP sounds very promising indeed! I just looked it up in my API reference...

to chensu:
Aktually no typo but delphi syntax - for C you're right of course
0
 

Expert Comment

by:Subramanya
Comment Utility
Test
0
 
LVL 1

Author Comment

by:Roadrunner100598
Comment Utility
DT_NOCLIP solved my problem!!!

Thanks a lot,

Roadrunner

(Sorry I took so long evaluating your comment)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now