Home > Software engineering >  About real participation LPWSTR LPCWSTR parameters of incompatible problem
About real participation LPWSTR LPCWSTR parameters of incompatible problem

Time:10-19

Using VS2012 programming, want to use in the MFC Date Time Picker space callback field, is basically in accordance with the instructions on the MSDN, url here:
https://msdn.microsoft.com/zh-cn/library/cc468269 (vs. 71). Aspx
Also directly copy and paste the code, and then the response DTN_FORMAT notice, code using the wsprintf function (note: when the cursor to the function display # define wsprintf wsprintfW), is the following two lines:
Wsprintf (pDTFormat1 - & gt; PszDisplay,
"% d", oCurTime GetDayOfYear ());
Then prompt me pDTFormat - & gt; PszDisplay LPCWSTR types of the parameters, and the type LPWSTR parameter incompatible
I tried to convert the first argument to cstrings type, and then converted to type LPWSTR, no error, but after the operation is not the desired effect,
Anyone know how to modify?

CodePudding user response:

Try using a static variable
 
The static TCHAR szBuff [64].
_stprintf_s (szBuff, 64, _T (" % d "), oCurTime. GetDayOfYear ());
PDTFormat1 - & gt; PszDisplay=szBuff;

CodePudding user response:

Don't use your engineering unicode environment

CodePudding user response:

Look at the document, you write in the incoming parameters is to revolt... <) _ _ (: 3)

CodePudding user response:

I think it is wrong to "% d"?
Should use _T (" % d)"

CodePudding user response:

reference 1st floor zgl7903 response:
use a static variable see
 
The static TCHAR szBuff [64].
_stprintf_s (szBuff, 64, _T (" % d "), oCurTime. GetDayOfYear ());
PDTFormat1 - & gt; PszDisplay=szBuff;

Thank you, solve the

CodePudding user response:

refer to the second floor cutmelon response:
you engineering don't use unicode environment

Use UNICODE environment has failed to solve the problem of not from LPCSTR to LPSTR conversion

CodePudding user response:

LPSTR (LPCSTR) STR

CodePudding user response:

You can use the following function transfers:
MultiByteToWideChar
WideCharToMultiByte
  • Related