Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Centering Blted Text
#1
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!
Reply
#2
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?
Reply
#3
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).
Reply
#4
But I heart verdana :[. There has to be another way.. Guess Im back to google.
Reply
#5
Just create a .bmp file with the verdana font in it using monospacing.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#6
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.
Reply
#7
Hey, blame DX7 not us ;DD

Drawing text directly sucks on all version of DX I've used.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)