DX7 Algning

LordHelmut
06-11-2002, 11:50 AM
Alright, I got a problem. In my game, I display the persons nickname below their character. I got that working fine but I cant figure out how to make it align correctly. I just did

Private Sub DrawText()
'line to print text out
Call ddsBackBuffer.DrawText(Player.X - 30, Player.Y + 50, "Lord Helmut", False)
End Sub

and that works fine but how could I fix that so no matter what text was the nick name (will be inputted from text file) is centered?

DrunkenHyena
06-13-2002, 11:32 PM
G'day!

There are actually quite a few ways to do it, but I think the simplest is to use GetTextExtentPoint32. I did a quick search on MSDN and here's a snippet:

The GetTextExtentPoint32 function computes the width and height of the specified string of text.

BOOL GetTextExtentPoint32(
HDC hdc, // handle to DC
LPCTSTR lpString, // text string
int cbString, // characters in string
LPSIZE lpSize // string size
);

Squirm
06-14-2002, 09:34 AM
Or use the DrawText API with the DT_CALCRECT flag. :)

LordHelmut
06-14-2002, 01:49 PM
Thanks guys, I used that site that squirm posted and looked Hyena's and I found this http://www.allapi.net/apilist/apifunction.php?apifunction=GetTextExtentPoint32 I am horrible with API so I guess I should start learning. I wish the gave sample code of how to use it hehe. Oh well, thanks you guys

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum