JohnIdol
November 14th, 2007, 09:10 AM
Hi everyone.
I am trying to draw some text I retrieve from file but somehow I can't get it to display correctly.
I am retrieving the text as LPCSTR but as I am building with unicode Drawtext is mapped to DrawTextW.
If I translate my LPCSTR to LPCWSTR with MultiByteToWideChar I see Chinese characters when displaying.
If I use explictly DrawTextA everything works fine BUT I can't get to work carriage return and line feed sequences...
this is my code:
static char strText[1000];
char* strTemp= (char *)myModel->GetInstructions();
strcpy(strText, strTemp);
int a = lstrlenA(strText);
BSTR unicodestr = SysAllocStringLen(NULL, a);
::MultiByteToWideChar(CP_ACP, 0, strText, a, unicodestr, a);
::SysFreeString(unicodestr);
g_pFont1->DrawText(g_pTextSprite,
(LPCWSTR) &unicodestr,
lstrlenW(unicodestr),
&textbox,
DT_LEFT | DT_WORDBREAK,
D3DXCOLOR( 0.0f, 0.0f, 0.0f, 0.8f ));
}
Any help would be appreciated!
thanks in advance,
JI
I am trying to draw some text I retrieve from file but somehow I can't get it to display correctly.
I am retrieving the text as LPCSTR but as I am building with unicode Drawtext is mapped to DrawTextW.
If I translate my LPCSTR to LPCWSTR with MultiByteToWideChar I see Chinese characters when displaying.
If I use explictly DrawTextA everything works fine BUT I can't get to work carriage return and line feed sequences...
this is my code:
static char strText[1000];
char* strTemp= (char *)myModel->GetInstructions();
strcpy(strText, strTemp);
int a = lstrlenA(strText);
BSTR unicodestr = SysAllocStringLen(NULL, a);
::MultiByteToWideChar(CP_ACP, 0, strText, a, unicodestr, a);
::SysFreeString(unicodestr);
g_pFont1->DrawText(g_pTextSprite,
(LPCWSTR) &unicodestr,
lstrlenW(unicodestr),
&textbox,
DT_LEFT | DT_WORDBREAK,
D3DXCOLOR( 0.0f, 0.0f, 0.0f, 0.8f ));
}
Any help would be appreciated!
thanks in advance,
JI