Solved

API:  DrawText() problem

Posted on 2000-03-23
9
1,041 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 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