473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

GetTextExtentPoint32 API

38 New Member
--------------------------------------------------------------------------------

When using this with the DrawText API, I make the rectangle that the text is contained in the width of the return value of GetTextExtentPoint32


I know I am using the right parameters, but sometimes the rectangle is way too big (over 15 pixels wider than the actual width of the text) and sometimes the rectangle is too small.



It seems that this API is a little.. screwed up perhaps? If I input "WWWWWWWWWWWW" for example, the rectangle containing the text is around 20 pixels too big but if I input "iiiiiiiiiiii", the rectangle is around 20 pixels too small.



I tried using SetTextCharacterExtra, but that just screwed things up even more. I'm looking for a more accurate and precise way to set the rectangle's width via the width of the text. Btw, there will never be any spaces, numbers, or symbols as the text. The width of the text will only ever contain the 26 lowercase letters and 26 uppercase letters.



Thanks for any help. :)
Jul 19 '07 #1
1 2783
weaknessforcats
9,208 Recognized Expert Moderator Expert
From the Microsoft docs:
Because some devices kern characters, the sum of the extents of the characters in a string does not always equal to the extent of the string.
Jul 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John Fullman | last post by:
Let's say I wanted the exact width of a string (in pixels) based on a certain font or device context. Anotherwords, how do I implement a funciton prototyped... int MeasureStringInPixels(HDC dc,...
1
by: Steve Richter | last post by:
is there a "GetTextExtentPoint32" equivalent in Windows Form or Font class? from the button text I would like to calculate the size that the button needs to be. thanks, -Steve
8
by: Shimrit Ben-Yair | last post by:
Hi, I'm having problems with the measureString function. I am trying to measure the length of a string the user types into a text box. However, the size in pixels that this function returns is...
6
by: Valerie Hough | last post by:
I'm not entirely sure what the difference is between these two approaches. In order to avoid reentrant code, I was using Control.BeginInvoke in my UI to cause an asynchronous activity to be done...
11
by: Pete Davis | last post by:
I have an app that's dealing with a few hundred bitmap thumbnails. I only instantiate the bitmaps that are visible at a given time and dispose of them if they get scrolled out of view. I've used...
0
by: Matt | last post by:
This took way to long to figure out - now that I have it working I thought I would share with the group. I've seen tons of posts with very little good answers on this seemingly simple thing that...
1
by: paii, Ron | last post by:
1
by: Oron.Morad | last post by:
Hello, I develop C#.NET (WinForm) over 2003server. I am looking for a way to adjust a component size (width pixels) according to a given text of a certain font (i.e font family, size and style)...
22
compman9902
by: compman9902 | last post by:
People, first of all thank you for reading my post. I would like to start off by saying that I have read Prorgramming Windows and I have found no information that contributes to what I need to do....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.