GetTextExtentPoint32 #2

Hi,

I have multiple problems here :(

I have a short text in UNICODE and the text contains newlines as well
(carriage return and newline)
and it seems that GetTextExtentPoint32 doesn't take into account the
newlines.

So I broke the lines myself and checked which has the longest length.

Also, for the "int cbString" parameter, if my text is "hello" and I pass 5,
then it doesn't return the current width.
I have to send 6. Yes, I do select my font in the HDC before calling this.

Other problem!
Interline spacing issue

Lines are separated by a certain mount of pixels it seems in DrawTextEx
How can I found out how many pixels that is?

Basically, I would like to know *accuratly* the width and height of a block
of text

Thanks for any hints



0
NULL3758 (62)
5/14/2006 4:13:41 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
1268 Views

Similar Articles

[PageSpeed] 34

On Sun, 14 May 2006 12:13:41 -0400, "Hanna-Barbera" <NULL@excite.com>
wrote:

>Hi,
>
>I have multiple problems here :(
>
>I have a short text in UNICODE and the text contains newlines as well
>(carriage return and newline)
>and it seems that GetTextExtentPoint32 doesn't take into account the
>newlines.
>
>So I broke the lines myself and checked which has the longest length.
>
>Also, for the "int cbString" parameter, if my text is "hello" and I pass 5,
>then it doesn't return the current width.
>I have to send 6. Yes, I do select my font in the HDC before calling this.
>
>Other problem!
>Interline spacing issue
>
>Lines are separated by a certain mount of pixels it seems in DrawTextEx
>How can I found out how many pixels that is?
>
>Basically, I would like to know *accuratly* the width and height of a block
>of text

You may not have much luck trying to second guess DrawTextEx with
GetTextExtentPoint32. From memory, if you look at the DrawTextEx
parameters, there is a DT_CALCRECT flag which will return the height of the
text (you provide the width). As for the inter-line spacing, again, you'd
be trying to second guess the function. If you care about such things, you
may need to draw the text yourself. If you're using the "longest length"
from GetTextExtentPoint32 to determine the DrawText width, this won't even
be difficult, as you won't have to perform any word wrapping.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
5/14/2006 9:15:29 PM
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:707f621e5lqrjfl7na26qopu3oe83enjoo@4ax.com...

> You may not have much luck trying to second guess DrawTextEx with
> GetTextExtentPoint32. From memory, if you look at the DrawTextEx
> parameters, there is a DT_CALCRECT flag which will return the height of
the
> text (you provide the width). As for the inter-line spacing, again, you'd
> be trying to second guess the function. If you care about such things, you
> may need to draw the text yourself. If you're using the "longest length"
> from GetTextExtentPoint32 to determine the DrawText width, this won't even
> be difficult, as you won't have to perform any word wrapping.
>

Thanks Doug,

DT_CALCRECT is interesting but I wish it would return the width as well. It
would make my life simpler.

Secondly, I haven't understood what's is the deal with GetTextExtentPoint32
If my string is "hello" and I pass 5, it returns a lower width. It's as if
"o" is beeing lost
If I pass longer text, multiple letters from the end seem to be lossed.

Also, I am using D3DX (the D3D library) to render the stuff and I am
assuming the function that I'm using from D3DX is identical to DrawTextEx
but it seems I could be wrong.

For the time being, I think I'll guesstimate it since it should do the job.


0
NULL3758 (62)
5/15/2006 1:45:37 PM
I guess it was an error on my part.

CreateFont(height, ....)

when I should had it as
CreateFont(-height, ....)

It makes a huge difference.

Thanks


0
NULL3758 (62)
5/15/2006 2:25:40 PM
On Mon, 15 May 2006 10:25:40 -0400, "Hanna-Barbera" <NULL@excite.com>
wrote:

>I guess it was an error on my part.
>
>CreateFont(height, ....)
>
>when I should had it as
>CreateFont(-height, ....)
>
>It makes a huge difference.

Yep, CreateFont is weird like that.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
5/15/2006 2:56:57 PM
Reply:

Similar Artilces:

help sos #2
error 421 smtp service is not available ...

Highlighting Cells #2
In columns A:F, the sheet is text. I would like to highlight a row in a color, (Say A5:F:5) when an "A" is typed into F:5 Can this be done? -- comotoman ------------------------------------------------------------------------ comotoman's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=27292 View this thread: http://www.excelforum.com/showthread.php?threadid=470747 Your question is confusing so I don't quite understand what you want to do. It sounds like you want conditional formatting. Here is what I think you want to do. If not please be ...

security_cookie referenced in function _WinMain #2
I am compiling this: http://www.haxorcitos.com/ficheros/minishell.zip with VC++ Exprees and Microsoft SDK platform for windows. I get this errors: MiniShell.obj : error LNK2019: unresolved external symbol ___security_cookie referenced in function _WinMain@16 MiniShell.obj : error LNK2019: unresolved external symbol @__security_check_cookie@4 referenced in function _WinMain@16 Not too much information about them in google. wich dll am I missing? What am I doing wrong? ...

Send Direct Email functionality #2
Hi all, I am using CRM 3.0. I am ultimately trying to find a way in Outlook to create an emailing group off of a list of CRM contacts to email that group of contacts. One alternative I found is to email said group from within CRM. As I investigated that, I learnt about the "send direct email" functionality from a contacts' view. This can be a view generated from Advanced Find then you click Actions --> Send Direct Email or something like that. However, I cannot find that functionality and don't know how to access it. There was some posts about the CRM Bulk email service ...

Exclude some assembly from .Net Compact Framework 2.0....
Hello, I'm working on Windows CE 5.0 and I have seen that when I include the .Net Compact Framework catalog item into my runtime image, there are some assemblies that I don't use (es. microsoft.visualbasic.dll, system.net.irda,...). To reduce the runtime image dimension I want to exlude these assemblies. Under PUBLIC\NETCFV2 there is the catalog item and I see that it copies the assembly files from PUBLIC\OTHERS\DOTNETV2\MANAGED. What is the right way ? I have to create a new catalog item or a new subproject ? Thanks, Paolo -- Paolo Patierno Embedded Software Engi...

Re: Re: api to check wheter xml is well formed #2
You mean the XmlTextReader. Ashish wrote: > Are there any functions in .Net which can be used to verify whether xml is > well formed? That's quite unusual requirement. Usually, when XML is built using XML API such as XmlTextWriter you don't need to check if it's well-formed - you can trust standard API. When your XML is loaded into in-memory store, such as XmlDocument - it's well-formed by definition. And when you just have a string or file and want to check it's well-formdness, use XmlTestReader: XmlReader r = new XmlTextReader(...); try { while (r.Read()...

change page setup from printing 1 business card to 2 rows of 5
the program wont let me make this simple change. all i want to do is set up the page so that it prints the card in two rows of 5 but there is no way to change it. Oh but there is, give this a try. Here's I do it with Publisher 2000. File Page Setup Special Size Business Card from the drop down menu OK Create card. Assuming you are using standard business card stock of 2 wide and 5 high; File Print Page options button Print multiple copies per sheet Custom options button Margins = .5" Gap = 0" Side Margins =...

kb926666 #2
Hi, I have exchange 2003 w/ sp2 on windows 2003 sp1. read article on: http://support.microsoft.com/kb/931836/ http://support.microsoft.com/?kbid=926666 http://support.microsoft.com/kb/931667/ got 931836 installed fine, but KB926666 gave "Set Error" you must have service pack 2 installed? anyone experience this problem? - I tried to uninstall kb931836, reboot, tried kb926666, no luck. - reinstall exchange sp2, reboot, again on kb926666, no luck. Thanks Sam sovled - reason, I got a different version of exch2k2 sp2 ver: Build 7623.0 Sp2 - download exchange sp2 again - now the b...

Microsoft .NET Framework 2.0: x86 (KB829019) & version 1.1
Hello Everyone in this network, I need help. I am not very computer savy. I tried to update the above two through Microsoft Update but am getting an error being Failed. Can someone help me with this. My system has windows XP with SP3. I am even unable to download certain softwares due to this i think. I had remote access to work system from home but since my computer crashed last time i am having all sorts of trouble. Please help. Thanking in advance, Bhavesh. ...

Outlook 2003 Beta 2
I have just installed and started playing with the Outlook 2003 Beta 2. The first thing I have noticed is that it does not notify me when new messages arrive - I have all the options turned on: make a sound, place an envelope in the tray, the new "desktop alert", but nothing happens. Any ideas? ...

exchange 2003 service pack 2
Does the increase in the mailbos storage size to 75 Gig apply to the Public Store also? -- Thanks Duane Hi Duane, For Exchange 2003 Standard Edition there will be 75Gb for the Public IS and another 75Gb for the Private IS. Regards -- Ben Hoffman MCP (Win2000 Pro/Server & Exchange 2003 Admin) http://www.ExchangeIS.com "Duane" <Duane@discussions.microsoft.com> wrote in message news:7A46B72B-4F8F-40ED-959B-614DC3BED6AD@microsoft.com... > Does the increase in the mailbos storage size to 75 Gig apply to the > Public > Store also? > -- > Thanks > Dua...

BadMail #2
How do I forward mail from the Badmail folder? I received an email with an attachment that was larger than the mail restrictions for that user therefore, it sent the item to the Badmail folder. I want to forward this to the Administrator account. I've tried just renaming the file (with .eml extension) which will allow me to open it but I can not see the attachment. I tried renaming with a .msg extension and it will not open at all. Thanks in advance, Enrique Dear Enrique, Thanks for posting here. When the e-mails come with an attachment that was larger than the mail restrictions...

Recovering mailboxes #2
I was just asked to restore all mailboxes back to 4 days ago. without disrupting production to allow HR to search for something. We have a Windows 2000 Server with Exchange 2003 installed. My question is what is the best way of doing this. Create a recovery group. Then create a mailbox store within the group, and then recover to that mailbox store. Or would I not create the mailbox store and then allow the backup software create the store during recovery. How would HR get access to the recovered mailboxes? On Tue, 19 Jul 2005 11:54:02 -0700, "Bruce" <Bruce@discussion...

Migrating from RMS 2.0 to POS 2009
Is there a white paper or deployment guide that sheds some light on the process of migrating a rms 2.0 database to POS 2009? I have scoured partnersource and come up empty. Thanks John Storlie This is a multi-part message in MIME format. ------=_NextPart_000_01D2_01CA15DF.084A0740 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable John, Did you look at the POS2k9 page? http://tinyurl.com/n7mdkl All kinds of = goodies there. In the Key Announcements section | POS2k9 Download link | Support Info = link | last line Rapid Implementation T...

Scatter with lines between corresponding points in 2 series?
I have a scatter showing two series: 1) GM% vs revenue by account 2) Pocket margin % vs revenue by account I'd like to draw lines between the corresponding points in the two series. For instance, if company A has revenue of 500k and GM% of 39% but pocket margin of 35%, I'd like to connect the points at (500k, 39%) and (500k, 35%). Is there an automated way to do that? Thanks Make a column with GM-Profit and use this a an error bar (just + or -) on one of the data series I am sending you a file best wishes -- Bernard V Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme re...

Can't install 12.2.1 on any computers 10.4-10.6
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel "You cannot install Office 2008 12.2.1 Update on this volume. A version of the software required to install this update was not found on this volume." I get this error on every computer in the building, PowerPC computers running 10.4 and Intel computers running 10.4, 10.5 and 10.6. All the computers currently have 12.2.0 and have all current OS updates. Any ideas? On 10/1/09 7:54 AM, in article 59b7db0d.-1@webcrossing.caR9absDaxw, "macinmypocket@officeformac.com" <macinmypocket@officeformac.com...

Help with rules not working #2
Hi: I'm continuing to experience problems with Rules working. This time, I have Outlook 2003 connected to Exchange 2000 Server, set up to run on a PC (Win XP pro). I'm connected to that PC with a remote desktop session that is always open. None of the rules work unless I run them manually (even rules that are server side). Does anyone know if a command line switch (or anything else) will work to ensure that rules actually run automatically? Thanks for any suggestions -- Dab Cut off: yourhead to respond ...

Filtering question #2
Usually when a filter is on and the data is filtered, in the bottom left hand corner of the screen it will provide you with the number of records found. For example, it may say that the filter applied produced "23 of 391 records found". If this function stops working does anyone know how to turn it back on? Thanks! IL y a des cas connus o� cela se produit, une solution �tant de passer en calcul manuel au lieu de automatique. (dans les options de calcul) Attention, cela signifie que lorsqu'une cellule est modifi�e, les autres ne se mettent plus � jour tout de suite mais qu'...

CountIF on 2 arguments
How do you COUNTIF on 2 arguments. ie I want to count the number of values "x" in column A only if column B's value = "y". I have seen many ref to SUMPRODUCT but I am not counting numbers. Thanks in advance for any assistance. David Maddern Hi no problem using SUMPRODUCT. Try =SUMPRODUCT((A1:A100="x")*(B1:B100="y")) or =SUMPRODUCT(--(A1:A100="x"),--(B1:B100="y")) -- Regards Frank Kabel Frankfurt, Germany david.maddern@uhsinc.com wrote: > How do you COUNTIF on 2 arguments. ie I want to count the > number of value...

please help OE & OL between 2 users
I am admin account and run Outlook. Girlfriend is limited account and runs OE. When she right clicks pics and the like to send to mail recepient, it opens an Outlook new message window. Now, these messages never get sent as she doesnt use Outlook as her email program. They simply accumulate in the Outlook outbox and never get sent. I cant set OE as her default email as it wont let me do that (I guess since Im admin and I use it). What should be done? Ive tried this all but the registry change http://support.microsoft.com/?kbid=306098 and it wont take. Whats the best way to do...

lost e-mail #2
I had a problem with my win 98 machine so i got xp pro and installed it over top of win 98. Well not knowing that it basically erases all of your programs i opened my outlook 2000 up and it told me i have to reintall the program. So i did that, and to my surprise all of my e- mails were gone. Is there any way to get all of those e- mails back. Look for files with a .PST extension -- a .PST file contains all Outlook data including messages, contacts, appointments, notes, etc. WinXP hides Outlook data files by default, so make sure to search in hidden and system folders. Look here for all...

Change Fiscal Periods #2
Using GP 9 and the fiscal year ends 10/31. Changing the Fiscal year to a calendar year starting 1/1/08. What is the best way to handle in GP and are there any potential issues with doing this? Thanks You have two options. 1. If the current year started 11/1, you can extend it two months and have a 14 month year ending 12/31/2008. If the current year is named 2008, this is your best option. 2. If you cant do that and MUST restart a fiscal year 1/1/2008, then first shorten the current year to 2 months and create a new year. If the current year being shortened is named 2008, you...

Outlook 2003
Hi All, We are currently on Office 2000 Pro, and are looking at whether to upgrade to 2003. Whilst there are many considerations, one point raised was the inability of OL2000 to send a personalised newsletter with an attachment. *Background* We send our newsletters by email, in PDF format as an attachment, along with a link to our website which also has a copy on it as part of the covering email body. As far as we have been able to ascertain, without using VBA, OL2000 can do a personalised newsletter (Dear XXXX where XXXX is a mail merge field from Word and changes for each email), but ...

Sum with conditions #2
Hi, I've read a lot of posts in this group about this issue, but I can't find a solution. I am using this array formula: {=SUMA(((ConsultaPosiciones!E2:E100)=B1)*(ConsultaPosiciones!J2:J100); 0)} But I get "#VALUE!# (translated from spanish). I found that the problem is with som empty cells in column "J", when I set the values of those cells the function works. The problem is that I cannot set those values due the huge amount of data. Is ther any way to ignore those empty cells? Thanks in advance. I don't have SUMA in Excel 2003. I've always done this...

OWA 2003 Issue (Attachment corruption) #2
Hello everyone, We have Front-End/Back-End configuration of Exchange 2003 Std. servers (SP2 and all hot fixes after it). So, if someone sends e-mail with attachment through OWA the attachment becomes corrupted (it has same size and name but could not be read by any application / system splits attachment and put 2 parts of it into message using the same name of file). It happens to all documents (Word, Excel, PDF) image files (JPG,GIF,PNG) are affected as well. We tried to send those files through usual MS Outlook 2003 and they go just perfect. We have McAfee Groupshield 6.02 for Exch...