RegisterClassEx
-
int WINAPI WinMain(::HINSTANCE__* instance, ::HINSTANCE__* prevInstance, char* cmdLine, int cmdShow) { ::WNDCLASSEX wndClass; ::HWND__* hwnd; ::MSG message; // Alle Objekte initialisieren ::ZeroMemory(&message, sizeof(::WNDCLASSEX)); ::ZeroMemory(&hwnd, sizeof(::HWND__*)); ::ZeroMemory(&message, sizeof(::MSG)); // WNDCLASSEX initialisieren wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.style = CS_VREDRAW | CS_HREDRAW; wndClass.lpfnWndProc = wndProc; wndClass.hInstance = instance; wndClass.hIcon = ::LoadIcon(nhNULL, IDI_APPLICATION); wndClass.hIconSm = ::LoadIcon(nhNULL, IDI_APPLICATION); wndClass.hCursor = ::LoadCursor(nhNULL, IDC_ARROW); wndClass.hbrBackground = static_cast<::HBRUSH__*>(::GetStockObject(0)); wndClass.lpszClassName = window::name; // Fenster registrieren if(!::RegisterClassEx(&wndClass)) { ::MessageBoxW(nhNULL, L"Programm nutzt Unicode und setzt WIndows NT voraus", window::name, MB_ICONERROR); return 0; } ...Warum kann der die Fensterklasse nicht registrieren? Bei mir gibt er die ErrorMessage aus. Ich nutze aber windows XP.
-
tuikghlhl schrieb:
Bei mir gibt er die ErrorMessage aus. Ich nutze aber windows XP.
Wenn RegisterClassEx fehlschlägt, kann das auch andere Ursachen haben. Was sagt denn GetLastError?
P.S.:
Kann es sein, dass du Doppeldoppelpunktitis hast?
-
WNDCLASSEX hat 12 Member, du initialisiert nur 9.
-
::WNDCLASSEX wndClass; ::HWND__* hwnd; ::MSG message; // Alle Objekte initialisieren ::ZeroMemory(&message, sizeof(::WNDCLASSEX)); // <--- ??? ::ZeroMemory(&hwnd, sizeof(::HWND__*)); ::ZeroMemory(&message, sizeof(::MSG));Meinst Du nicht
::ZeroMemory(&wndClass, sizeof(::WNDCLASSEX));?
Dann sollten auch die fehlenden Member verziehen werden, initialisier sie trotzdem besser mit NULL.WNDCLASSEX wcx; // Fill in the window class structure with parameters // that describe the main window. wcx.cbSize = sizeof(wcx); // size of structure wcx.style = CS_HREDRAW | CS_VREDRAW; // redraw if size changes wcx.lpfnWndProc = MainWndProc; // points to window procedure wcx.cbClsExtra = 0; // no extra class memory wcx.cbWndExtra = 0; // no extra window memory wcx.hInstance = hinstance; // handle to instance wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION); // predefined app. icon wcx.hCursor = LoadCursor(NULL, IDC_ARROW); // predefined arrow wcx.hbrBackground = GetStockObject( WHITE_BRUSH); // white background brush wcx.lpszMenuName = "MainMenu"; // name of menu resource wcx.lpszClassName = "MainWClass"; // name of window class wcx.hIconSm = LoadImage(hinstance, // small class icon MAKEINTRESOURCE(5), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);Quelle: MSDN