DirectX fonts

Started by
13 comments, last by Zombie 24 years, 2 months ago
trixter-
I have to be more specific next time - of course I meant
runtime check.
Advertisement
Tuan, what is the device context in DirectX? Example please...
I assume that you are using Visual Basic since DrawText is a VB only function. You must declare GetTextExtentPoint32 like this:

Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As SIZE) As Long

Then call it. Since I never used it, look it up somewhere.
You can get the device context of DirectDrawSurface:

void GetTextSize(char* text, HFONT hFont, SIZE& size)
{
HDC hdc;
HFONT oldfont;
gDDSurface->GetDC(&hdc);
// Try with GDI functions
oldfont = (HFONT) SelectObject(hdc, hFont);
//SetBkMode(hdc, TRANSPARENT);
//SetTextAlign(hdc, TA_LEFT / TA_TOP / TA_NOUPDATECP);
GetTextExtentPoint32(hdc, text, strlen(text), &size);
SelectObject(hdc, oldfont);
gDDSurface->ReleaseDC(hdc);
}

Goodluck.
Yes, I''m using and don''t understand anything about that C code. I have the declaration too (api viewer is for that), but I have no idea how to get it working. To what i should use the SIZE?

This topic is closed to new replies.

Advertisement