来自wchar_t的C ++ Win32 GDI +抽取*

时间:2014-09-22 07:12:03

标签: c++ winapi

我已经完成了搜索并花了至少一个小时的时间。

wchar_t* fooBar = (wchar_t*)L"BlahBlah\0";
//GetWindowText(pDIS->hwndItem, (wchar_t*)fooBar, 64); 
g->DrawString(fooBar, -1, &font, rectf, &strFormat, textColorUp);

这有效,并且编译;因为字符串是正确绘制的“BlahBlah。”

问题是我想使用我已经评论过的GetWindowText()的值。

转换可能有问题,但我找不到它。

1 个答案:

答案 0 :(得分:4)

您需要为要写入的GetWindowText函数分配空间。您无法提供字符串文字的地址,因为它们不可修改。

wchar_t buffer[1024];
GetWindowText(pDIS->hwndItem, buffer, _countof(buffer));
g->DrawString(fooBar, -1, &font, rectf, &strFormat, textColorUp);