Mirage Source
Centering Blted Text - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: Centering Blted Text (/showthread.php?tid=1660)



Centering Blted Text - seraphelic - 05-04-2008

In my journey to center text, I ran across a gdi32 api call dubbed GetTextExtentPoint which measures dimensions of specified text in hdc. The only problem is, I get a "User-Defined Type Not Defined" when adding the function:
Code:
Public Declare Function GetTextExtentPoint Lib "gdi32" Alias "GetTextExtentPointA" (ByVal hDC As Integer, ByVal lpszString As String, ByVal cbString As Integer, ByRef lpSize As Size) As Integer
Can't figure out why it won't recognise it. Help!!

Even better, if you have a operable center solution, pm me Tongue

Thanks in advance!


Re: Centering Blted Text - seraphelic - 05-04-2008

Thanks, I got it working. Only problem is, the size is way off!! :[ What's going on?

Took a screenie of mirage. a 31px name was reported as 43px. a 30px name was reported as 37px. Any help?


Re: Centering Blted Text - seraphelic - 06-04-2008

Good point, but both words described had 6 letters. In paint, the difference in the words' pixel width was 1; the buffer should be constant im guessing, or else there would be no way to measure width with this method. So making these assumptions, I cannot fathom why the names "Jables" and "tester" would come out with a 6 pixel difference using this function >.>

If anyone has a working system, please help. If there's another method give me a hint, I like figuring things out on my own (if theyre in my capacity).


Re: Centering Blted Text - seraphelic - 06-04-2008

But I heart verdana :[. There has to be another way.. Guess Im back to google.


Re: Centering Blted Text - Robin - 06-04-2008

Just create a .bmp file with the verdana font in it using monospacing.


Re: Centering Blted Text - seraphelic - 09-04-2008

So I actually got GetTextExtentPoint32 to work in a seperate project, and I think I figured out the problem. For some reason the GAME_SIZE has to be an extra 5 to display the correct size. If someone doesn't already have a fix for this, I'm going to redo the dx text system because it SUCKS.


Re: Centering Blted Text - Robin - 09-04-2008

Hey, blame DX7 not us ;DD

Drawing text directly sucks on all version of DX I've used.