Data Conversion
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]
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.
/start code
Graphics Gfx(hdc);
SYSTEMTIME NextRunTime;
result = pITask->GetNextRunTime(&NextRunTime);
pITask->Release()
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.
-Vlarr
Graphics Gfx(hdc);
SYSTEMTIME NextRunTime;
result = pITask->GetNextRunTime(&NextRunTime);
pITask->Release()
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.
-Vlarr
sprintf() it into a char[] array, or use std::string.
Then pass that array/string into the DrawString function.
like:
Then pass that array/string into the DrawString function.
like:
char buffer[100]; sprintf(buffer,"NextRunTime: %i",NextRunTime.wMonth); Gfx.DrawString(buffer,-1, &fnt, dateText, &whiBrush);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement