Jump to content
  • Advertisement


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


Data Conversion

This topic is 5646 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

Is it possible to convert WORD to WCHAR? Reason I asked is because I'm trying to gather information from a task in the MS Task Scheduler using the SYSTEMTIME structure. I would use wprintf() except that I want to display the information using the GDI+ Graphics class DrawString() method but it wants a const WCHAR *string. Is there an easier way to do this or am I just missing the obvious? I've tried countless google searches and the closest I've come is finding how to convert them the other way around. -Vlarr [edited by - Vlarr on January 30, 2003 11:49:57 AM]

Share this post

Link to post
Share on other sites
In Win32, at least, the only difference is: WORD is an unsigned short, WCHAR a signed short. You should be able to cast between them without a problem, though I don''t know what will happen with your particular functions.

Share this post

Link to post
Share on other sites
/start code

Graphics Gfx(hdc);

result = pITask->GetNextRunTime(&NextRunTime);


Gfx.DrawString(NextRunTime.wMonth,-1, &fnt, dateText, &whiBrush);

/end code

Obviously the compiler complains about the first parameter of DrawString() but it illustrates what I''m trying to do.

From what I can tell .wMonth is type WORD and the first parameter of DrawString requires const WCHAR*, but casting just brings all sorts of nasty problems. I tried both static_cast and reinterpret_cast.


Share this post

Link to post
Share on other sites
sprintf() it into a char[] array, or use std::string.

Then pass that array/string into the DrawString function.


char buffer[100];
sprintf(buffer,"NextRunTime: %i",NextRunTime.wMonth);
Gfx.DrawString(buffer,-1, &fnt, dateText, &whiBrush);

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!