@EmmanuelC
I know nothing about this, but...
The example above (@JKSH) using fromWinId() called it on the result of a FindWindow() for a window from another process, externalWindow. https://doc.qt.io/qt-5/qwindow.html#fromWinId says:
Creates a local representation of a window created by another process or by using native libraries below Qt.
You have a CWnd, from an internal window I believe. I don't know how that plays.
As I said, I know nothing, so I probably can't say much more than this....