If you use the HWND returned by the CreateWindowEx() make sure it is declared as a STATIC HWND, or the value will be lost once the WM_INIT msgs completes (and not be valid for any other msgs).