Problem with DrawText function

Started by
2 comments, last by LordFallout 17 years, 10 months ago
Hello everyone im following a book intro to dx9 and having problems compiling the following code

char FPSString[9];



		Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
		Device->BeginScene();

		if( Font )
			Font->DrawText(20, 20, 0xff000000, FPSString);	

		Device->EndScene();
		Device->Present(0, 0, 0, 0);


and keep getting the following compile error c:\documents and settings\terry\desktop\intro to directx 10 source code\part 3\chapter 9\cfont\cfont.cpp(90) : error C2664: 'CD3DFont::DrawTextW' : cannot convert parameter 4 from 'char [9]' to 'const TCHAR *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast any way to resolve this i didnt want to make a lot more changes to the code as it messes it up more, lol o.o maybe im just being a noob and cant see the solution, thanks in advance
Advertisement
ok so i changed FPSString from char to const TCHAR * and off course now i'm getting complie error

c:\documents and settings\terry\desktop\intro to directx 10 source code\part 3\chapter 9\cfont\cfont.cpp(75) : error C2664: 'sprintf' : cannot convert parameter 1 from 'TCHAR *[9]' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

that doesnt work, any suggestions from anyone?
Turn it back into a character array, and in your call to "DrawText", just make a simple C-style cast, "(TCHAR*)FPSString". I think you only need a special conversion function if you're dealing with Unicode, which Windows labels as "WCHAR*".
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
thanks a lot for the help, worked great don't know why i didnt think off doing it first also using this method to solve similar problems i keep getting with strcpy :)

This topic is closed to new replies.

Advertisement