[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Drawtext

Posted on 2013-12-16
2
Medium Priority
?
212 Views
Last Modified: 2013-12-16
Hi!

What precisely should Drawtext with DT_CALCRECT return? Specifications say that it returns the rectangle needed for the text, but it doesn't!

I have a fixed width font where I run DrawText/DT_CALCRECT for both the string "9" and the string "99". They return a width of 9 and 18. By drawing vertical lines I can clearly see that I need to add 7 to move a vertical line one character and 14 to move it 2 characters. So why does Drawtext return 9??? GetTextExtent and GetTextMetrics all return 9 for the character width as well.

I run this from within a routine that is called during drawing of a control, so the DC has the correct font selected already (I think).

Thanks for any help!

P.S.: This is a simplified version of my question http://www.experts-exchange.com/Microsoft/Development/Q_28317440.html, since I got no response to that so far.
0
Comment
Question by:Knut Hunstad
[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
  • 2
2 Comments
 
LVL 8

Author Comment

by:Knut Hunstad
ID: 39721250
Oh, yes, I forgot: the space needed for the text "9" is actually only 6 and for "99" it's 13, since there is a space between each character...
0
 
LVL 8

Accepted Solution

by:
Knut Hunstad earned 0 total points
ID: 39721351
I found the problem. I was using this with a Stingray CGXEditControl, in it's GetCellRect. What happened was that GetDC within GetCellRect did not return the same DC as the on in Draw!

So now I calculate the necessary width in Draw() and use it in GetCellRect.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

656 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