Solved

API:  DrawText() problem

Posted on 2000-03-23
9
1,036 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2648453
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
ID: 2648487
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
ID: 2648644
To MDarling:
I normally use DT_CALCRECT first.
I even tried DT_CALCRECT, then added some pixels to Rect.Right... no use.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 3

Expert Comment

by:MDarling
ID: 2648677
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
 
LVL 12

Accepted Solution

by:
pjknibbs earned 150 total points
ID: 2648709
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
ID: 2650415
'543210' should be "543210". I suppose it is just a typo.
0
 
LVL 1

Author Comment

by:Roadrunner100598
ID: 2650482
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
ID: 2651053
Test
0
 
LVL 1

Author Comment

by:Roadrunner100598
ID: 2679486
DT_NOCLIP solved my problem!!!

Thanks a lot,

Roadrunner

(Sorry I took so long evaluating your comment)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 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