[C++]Probleme mit WinApi 2 Button erstellen

CodeCrafterCpp

Erfahrenes Mitglied
Hallo,
Kurze frage und zwar warum wird bei mir der 2 Button nicht angezeigt?



Code:
#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
                   PSTR szCmdLine, int iCmdShow)
{
   MSG        msg;
   HWND       hWnd;
   WNDCLASS   wc;
   
   const char szAppName[]  = "Windows Buttons";
   
   wc.cbClsExtra           = 0;
   wc.cbWndExtra           = 0;
   wc.hbrBackground        = (HBRUSH) GetStockObject(WHITE_BRUSH);
   wc.hCursor              = LoadCursor(NULL, IDC_ARROW);
   wc.hIcon                = LoadIcon(NULL, IDI_APPLICATION);
   wc.hInstance            = hInstance;
   wc.lpfnWndProc          = WndProc;
   wc.lpszClassName        = szAppName;
   wc.lpszMenuName         = NULL;
   wc.style                = CS_HREDRAW | CS_VREDRAW;
   
   RegisterClass(&wc);
   
   hWnd = CreateWindow(    szAppName,
                           szAppName,
                           WS_OVERLAPPEDWINDOW,
                           CW_USEDEFAULT,
                           CW_USEDEFAULT,
                           350,
                           200,
                           NULL,
                           NULL,
                           hInstance,
                           NULL);
   
   ShowWindow(hWnd, iCmdShow);
   UpdateWindow(hWnd);
   
   while (GetMessage(&msg, NULL, 0, 0))
   {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
   }
   
   return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HWND ExitButton;
	static HWND Button1;

	switch (message)
	{
		case WM_CREATE:
		{
			   ExitButton = CreateWindow("button",
									  "Exit",
									  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
									  0, 0, 0, 0,
									  hWnd,
									  NULL,
									  ((LPCREATESTRUCT) lParam) -> hInstance,
									  NULL);
			 return 0;
			 Button1 = CreateWindow( "button",
									 "1Button",
									  WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
									  0, 0, 0, 0,
									  hWnd,
									  NULL,
									  ((LPCREATESTRUCT) lParam) -> hInstance,
									  NULL);
			 return 0;
		}
		case WM_SIZE:
		{
				MoveWindow(ExitButton, 250 , HIWORD(lParam) - 30, 
															   80, 22, TRUE);
				MoveWindow(Button1, 150 , HIWORD(lParam) - 30, 
															   80, 22, TRUE);
				return 0;
		}

			case WM_COMMAND:
			 {
				if (lParam == (LPARAM)ExitButton)
				{
					if (HIWORD(wParam) == BN_CLICKED)
					 SendMessage(hWnd, WM_CLOSE, 0, 0);
				}
				if (lParam == (LPARAM)Button1)
				{
					if (HIWORD(wParam) == BN_CLICKED)
					 SendMessage(hWnd, WM_CLOSE, 0, 0);
				}
			return 0;
			}




			case WM_DESTROY:
			{
				PostQuitMessage(0);
				return 0;
			}
		}
		return DefWindowProc(hWnd, message, wParam, lParam);
}


mfG und die Hoffnung das der Fehler nicht ganz zu dumm ist :D
 
die Hoffnung das der Fehler nicht ganz zu dumm ist
Ist denn dieser Fehler dumm? ;)
Zumindest ärgerlich.
C++:
ExitButton = CreateWindow("button",
                                      "Exit",
                                      WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                      0, 0, 0, 0,
                                      hWnd,
                                      NULL,
                                      ((LPCREATESTRUCT) lParam) -> hInstance,
                                      NULL);
             return 0;  // <-- Fehler
 
Zurück