I have this problem that drives me crazy, so I'm here to ask for your help. I have this code that should create a simple window and show it:
void ShowMainWindow() {
WNDCLASSEX main_window_class;
main_window_class.cbSize = sizeof(WNDCLASSEX);
main_window_class.style = CS_PARENTDC|CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
main_window_class.lpfnWndProc = MainProc;
main_window_class.cbClsExtra = 0;
main_window_class.cbWndExtra = 0;
main_window_class.hInstance = Instance;
main_window_class.hIcon = LoadIcon(Instance, MAKEINTRESOURCE(MICON));
main_window_class.hCursor = LoadCursor(NULL, IDC_ARROW);
main_window_class.hbrBackground = HBRUSH(COLOR_WINDOW + 1);
main_window_class.lpszClassName = L"MyAppClass";
main_window_class.hIconSm = LoadIcon(Instance, MAKEINTRESOURCE(SICON));
if (!RegisterClassEx(&main_window_class)) {
MessageBox(NULL, L"RegisterClassEx", L"Error", MB_OK|MB_ICONERROR);
}
MainWindow = CreateWindowEx (
WS_EX_APPWINDOW,
main_window_class.lpszClassName,
(WCHAR*)"App Title",
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
600,
400,
NULL,
NULL,
Instance,
NULL
);
if (!MainWindow) {
MessageBox(NULL, L"CreateWindowEx", L"Error", MB_OK|MB_ICONERROR);
}
long Style = GetWindowLong(MainWindow, GWL_STYLE);
Style &= ~WS_MAXIMIZEBOX;
SetWindowLong(MainWindow, GWL_STYLE, Style);
ShowWindow(MainWindow, SW_SHOWNORMAL);
UpdateWindow(MainWindow);
My problem is that when I open the window, the window title is not “Application Name”, but some strange characters plus “CreateWindowEx”. This is so strange. It looks like this text from the MessageBox function is assigned to the window title. I must indicate that I am using UNICODE encoding. In any case, this has never happened to me before, and I just don’t know what might be wrong. Thank!
source
share