Re: Changing part program to display UNICODE strings
"pfArt" <pfArts@gmail.com> wrote in message
news:1173363250.440938.95230@v33g2000cwv.googlegroups.com
Thanks for the fast reply.
Maybe there's something else wrong with my code then...
I'm displaying strings in a custom drawed dialog box.
Here is a example of the Static textbox
HWND CreateStaticText(HINSTANCE hInst,int Left,int Top,int Width,int
Height,CString Msg)
{
HWND tmpHwnd;
tmpHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "STATIC",
(LPCTSTR)Msg,WS_CHILD | WS_VISIBLE
,Left,Top,Width,Height, parentHwnd, NULL, hInst, NULL);
SendMessage(tmpHwnd,WM_SETFONT,(WPARAM)Verdana,0);
Is Verdana a HFONT?
return tmpHwnd;
}
You need to use W for any API function that processes strings and you should
enter string literals as L"string" rather than as plain "string".
The following works for me:
HWND tmpHwnd;
WCHAR str[]=L"Unicode string";
LOGFONTW lf={0};
wcscpy(lf.lfFaceName, L"Times New Roman");
HFONT hfont = CreateFontIndirectW(&lf);
tmpHwnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"STATIC",
str, WS_CHILD | WS_VISIBLE,
Left,Top,Width,Height, parentHwnd, NULL, hInst, NULL);
SendMessageW(tmpHwnd, WM_SETFONT, (WPARAM)hfont, 0);
--
John Carson