1

我制作状态栏的代码在这里:

int statwidths[] = {300, -1};
HWND hStatus;

hStatus = GetDlgItem(hWnd, IDC_MAIN_STATUS);
SendMessage(hStatus, WM_SIZE, 0, 0);

hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL,
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 20, 20, 20, 5,
hWnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL);
SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);

//SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Loading things...");
SetWindowText(hStatus, (LPCWSTR)"sdgsdfgd");

设置状态栏文本的任何一种底部方法都只会给出乱码的中文字符

4

1 回答 1

1

以下行有问题

SetWindowText(hStatus, (LPCWSTR)"sdgsdfgd");

它应该是

SetWindowTextW(hStatus, L"sdgsdfgd");

此外,所有这些都取决于窗口是 UNICODE 还是 ANSI。

于 2012-11-21T05:43:56.580 回答