Solved

API:  DrawText() problem

Posted on 2000-03-23
9
1,034 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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