Quote: c:\documents and settings\jyt\my documents\visual studio 2005\projects\ch6\ch6\core_graphics.cpp(981) : error C2664: 'strcpy' : cannot convert parameter 1 from 'WCHAR [32]' to 'char *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\documents and settings\jyt\my documents\visual studio 2005\projects\ch6\ch6\core_graphics.cpp(989) : error C2664: 'D3DXCreateFontIndirectW' : cannot convert parameter 2 from 'LOGFONT *__w64 ' to 'const D3DXFONT_DESCW *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast c:\documents and settings\jyt\my documents\visual studio 2005\projects\ch6\ch6\core_graphics.cpp(1004) : error C2039: 'Begin' : is not a member of 'ID3DXFont' c:\program files\microsoft directx sdk (october 2006)\include\d3dx9core.h(314) : see declaration of 'ID3DXFont' c:\documents and settings\jyt\my documents\visual studio 2005\projects\ch6\ch6\core_graphics.cpp(1013) : error C2039: 'End' : is not a member of 'ID3DXFont' c:\program files\microsoft directx sdk (october 2006)\include\d3dx9core.h(314) : see declaration of 'ID3DXFont' c:\documents and settings\jyt\my documents\visual studio 2005\projects\ch6\ch6\core_graphics.cpp(1034) : error C2660: 'ID3DXFont::DrawTextW' : function does not take 5 argumentsand here is the code that is causing the problem
[source lang = "cpp"]
cFont::cFont()
{
m_Font = NULL;
}
cFont::~cFont()
{
Free();
}
ID3DXFont *cFont::GetFontCOM()
{
return m_Font;
}
BOOL cFont::Create(cGraphics *Graphics, char *Name, long Size, BOOL Bold, BOOL Italic, BOOL Underline, BOOL Strikeout)
{
LOGFONT lf;
if(Graphics == NULL || Name == NULL)
return FALSE;
if(Graphics->GetDeviceCOM() == NULL)
return FALSE;
// Clear out the font structure
ZeroMemory(&lf, sizeof(LOGFONT));
// Set the font name and height
strcpy(lf.lfFaceName, Name); //the strcpy problem
lf.lfHeight = -Size;
lf.lfWeight = (Bold == TRUE) ? 700 : 0;
lf.lfItalic = Italic;
lf.lfUnderline = Underline;
lf.lfStrikeOut = Strikeout;
// Create the font object
if(FAILED(D3DXCreateFontIndirect(Graphics->GetDeviceCOM(), &lf, &m_Font))) //D3DXCreateFontIndirect error
return FALSE;
return TRUE;
}
BOOL cFont::Free()
{
ReleaseCOM(m_Font);
return TRUE;
}
BOOL cFont::Begin()
{
if(m_Font == NULL)
return FALSE;
if(FAILED(m_Font->Begin())) //ID3DXFont error
return FALSE;
return TRUE;
}
BOOL cFont::End()
{
if(m_Font == NULL)
return FALSE;
if(FAILED(m_Font->End()))
return FALSE;
return TRUE;
}
BOOL cFont::Print(char *Text, long XPos, long YPos, long Width, long Height, D3DCOLOR Color, DWORD Format)
{
RECT Rect;
if(m_Font == NULL)
return FALSE;
if(!Width)
Width = 65535;
if(!Height)
Height = 65536;
Rect.left = XPos;
Rect.top = YPos;
Rect.right = Rect.left + Width;
Rect.bottom = Rect.top + Height;
if(FAILED(m_Font->DrawText(Text, -1, &Rect, Format, Color)))
return FALSE;
return TRUE;
}