我有这个程序:
#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两个字节的编码…
先进的保存选项编码设置为单字节一 – 赢1251。
我想要使用完全ANSI版本和我的窗口标题只包含ANSI字符。
你的窗口过程需要调用DefWindowProcA
。