Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DarrenKarstens

LPCWSTR

This topic is 5626 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to use the DrawText command from a D3DXFONT object. The first paramater is of type LPCWSTR which from what I can work out is some kind of pointer to a string. The text im trying to display is in string format but I can''t seem to convert the string into LPCWSTR format. Any help with this problem would be greatly recieved. Darren Karstens.

Share this post


Link to post
Share on other sites
Advertisement
All you need to do to draw a text is put the text in quotes, or if you want a number or series of numbers and text to appear use the sprintf function.

Here are 2 examples:

RECT rect={0,0,200,100};


char FPS[20];
float FramesPerSecond=1/timeGetTime();

sprintf(FPS,"Frames per second %0.2f",FramesPerSecond);

Font->DrawText(FPS,-1,&rect,0,0xffffffff);

or

Font->DrawText("THis will appear on the screen",
-1,&rect,0,0xffffffff);


Share this post


Link to post
Share on other sites
I would use sprintf to create your string like I described above,

or you could just declare

char string[]="This is a string";

or

char *string="This is a string";

then Font->DrawText(string,-1,&rect,0xffffffff);

Share this post


Link to post
Share on other sites
LPCWSTR == (const) pointer to wide (2 byte unicode) string.

Define your string literals as WCHAR arrays like this:
WCHAR myString[] = L"the string";

The L in front of the quotes tells the compiler to use unicode encoding rather than ANSI. To pass a pointer, just pass the array name or use the address of the first character

LPCWSTR pWideString = myString;
or
LPCWSTR pWideString = &myString[0];


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

[edited by - Paradigm Shifter on January 28, 2003 7:18:28 AM]

[edited by - Paradigm Shifter on January 28, 2003 7:20:51 AM]

Share this post


Link to post
Share on other sites
Everyone seems to be missing the fact that he is using the wide string version, he must be compiling for UNICODE.

There are portable versions of the string types, check out TCHAR, the TEXT("stuff") macro (or _T("stuff")), and functions like _stprintf.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!