title: Qt transparent child window with WS_EX_LAYERED always fails
body: <p>I'm integrating libVLC in a Qt Quick application on Windows by creating a child window and passing the handle of the window to libVLC to render the video.</p>
  
  <p>This works fine.</p>
  
  <p>However, I'm trying to create the child window with the <code>WS_EX_LAYERED</code> style in order to apply some transparency to it. I simply cannot get it working.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>    const auto parentWindow = quickWindow()-&gt;winId(); //The native window handle
  
      const auto windowClassName = QString("VLCWindow-").append(QString::number(reinterpret_cast&lt;int64_t&gt;(this), 16)).toStdWString();
      WNDCLASSEXW wcx = {};
      wcx.cbSize = sizeof(wcx);
      wcx.style = CS_HREDRAW | CS_VREDRAW;
      wcx.lpfnWndProc = DefWindowProcW;
      wcx.hbrBackground = static_cast&lt;HBRUSH&gt;(::GetStockObject(BLACK_BRUSH));
      wcx.hInstance = ::GetModuleHandle(nullptr);
      wcx.lpszClassName = windowClassName.data();
      if (!::RegisterClassExW(&amp;wcx)) {
          const auto lastError = ::GetLastError();
          if (lastError != ERROR_CLASS_ALREADY_EXISTS) {
              qCritical() &lt;&lt; "RegisterClassEx failed:" &lt;&lt; lastError;
              return;
          }
      }
      const auto nativeWindowHandle = ::CreateWindowExW(WS_EX_LAYERED, wcx.lpszClassName, L"", WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0, reinterpret_cast&lt;HWND&gt;(parentWindow), nullptr, ::GetModuleHandle(nullptr), nullptr);
      if (nativeWindowHandle) {
          qInfo() &lt;&lt; "Created native window for VLC rendering; handle:" &lt;&lt; nativeWindowHandle;
      } else {
          auto err = ::GetLastError();
          qCritical() &lt;&lt; "CreateWindowEx failed:" &lt;&lt; err;
          return;
      }
  </code></pre>
  
  <p>The above <code>CreateWindowExW</code> always fails with <code>GetLastEror()</code> returning 0!
   As soon as I remove <code>WS_EX_LAYERED</code>, everything is fine, but I need the <code>WS_EX_LAYERED</code>.
  I am running the code on a Windows 10, so the limitation of <code>WS_EX_LAYERED</code> on a pre-Windows 8 doesn't apply.</p>
  
  <p>I tried the following:</p>
  
  <ul>
  <li><p>calling <code>CreateWindowsExW(0, ...</code>  (which succeeds) and then call <code>SetWindowLongPtrW</code> to apply <code>WS_EX_LAYERED</code>, but <code>SetWindowLongPtrW</code> returns 0 and <code>GetLastError</code> also returns 0!</p></li>
  <li><p>passing my own <code>lpfnWndProc</code> to <code>RegisterClassEx</code> where I logged all the message types received; the only message I get is a <code>WM_NCDESTROY</code>, without any <code>WM_NCCREATE</code> sent before!</p></li>
  </ul>
  
  <p>Many thanks!</p>