trixter-
I have to be more specific next time - of course I meant
runtime check.
DirectX fonts
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement