title: C++ Window losing focus when child button is pressed
body: <p>I am trying to get a GUI running for a C++ application but I am having an issue with key press events. Basically, everything works fine, as long as I do not click on any buttons (the main window registers key events), but as soon as I click on a button, the main window loses focus and it no longer captures key events. This might be a stupid question, but I am very new to C++. This is some of the code I am using:</p>
  
  <p>Creation of the main window:</p>
  
  <pre><code>hwnd = CreateWindowEx (
                 0,                   /* Extended possibilites for variation */
                 szClassName,         /* Classname */
                 "Application Name",  /* Title Text */
                 WS_OVERLAPPEDWINDOW, /* default window */
                 CW_USEDEFAULT,       /* Windows decides the position */
                 CW_USEDEFAULT,       /* where the window ends up on the screen */
                 540,                 /* The programs width */
                 250,                 /* and height in pixels */
                 HWND_DESKTOP,        /* The window is a child-window to desktop */
                 NULL,                /* No menu */
                 hThisInstance,       /* Program Instance handler */
                 NULL                 /* No Window Creation data */
             );
  </code></pre>
  
  <p>Creation of one of the buttons:</p>
  
  <pre><code>CreateWindow(TEXT("button"), TEXT("Start"),
                   WS_VISIBLE | WS_CHILD,
                   x, y, width, height,
                   hwnd, (HMENU) 6, NULL, NULL);
  </code></pre>
  
  <p>I have also noticed that whenever I click on a button, the <code>WM_KILLFOCUS</code> event is fired, which is why I think that this is a focus issue. I have also tried capturing the WM_KILLFOCUS event and then set the focus again with <code>SetActiveWindow</code> but that crashed my program.</p>
  
  <p>Any help would be appreciated :)</p>