3

我有这个程序:

#include <Windows.h>

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_CLOSE:
            PostQuitMessage(0);
            break;

        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }

    return 0;
}

int main()
{
    WNDCLASSA wnd_class = { 0 }; 
    wnd_class.lpfnWndProc = WndProc;
    wnd_class.hInstance = GetModuleHandle(NULL);
    wnd_class.lpszClassName = "actwnd";

    RegisterClassA(&wnd_class);

    HWND main_wnd = CreateWindowA(wnd_class.lpszClassName, "Program activation", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 640, 480, NULL, 0, wnd_class.hInstance, NULL);

    MSG msg = { 0 };
    while(GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}

我不明白为什么窗口标题显示不正确:

在此处输入图像描述

看起来我的原因是未知的,有些东西仍然认为这是 unicode 两字节编码......

文件高级保存选项编码设置为单字节一 - win 1251。

我想完全使用 ANSI 版本,我的窗口标题只包含 ANSI 字符。

4

1 回答 1

8

您的窗口过程需要调用DefWindowProcA.

于 2013-08-01T11:28:12.437 回答