Standard Button wird nicht angezeigt
-
Hoi,
Hab ein Problem mit dem Anzeigen eines Buttons als Child-Window. Das Hauptfenster erscheint zwar, aber der Button wird scheinbar nicht erstellt.
[...] ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW;//CS_OWNDC wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TEST4); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCSTR)IDC_TEST4; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; TCHAR szHello[MAX_LOADSTRING]; LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); HWND hButton; switch (message) { case WM_CREATE: { hButton = CreateWindow( "button", "Knopf", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, hWnd, NULL, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); return 0 ; } [...]
-
Wie soll man den Button denn sehen? Die Größe des Buttons ist ja 0 x 0. Kein Wunder wenn man ihn nicht sieht. Einfach die Werte für die Größe mal auf ein paar andere Werte setzen:
CreateWindow( "button", "Knopf", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 100, 100, // <--- Werte für die Größe geändert hWnd, NULL, ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
-
Hups, das war jetzt zu billig

Da hatte ich wohl n Brett vorm Kopf, danke jedenfalls