Hi Yannis;
This is an issue in the Dockable Windows style where the GetSheet() related commands do not work on Dockable, Document or TabGroup based Sheets within an MDI Dockable frame. I opened ticket # 1312 last year ( and a few others ) for this type of related issue.
I was easily able to get around these issues in my STD Integrated Framework as it has long had a Window Manager service. I modified the service in the PB12.6 era (where the Dockable Window feature was released) to track how a main window were opened within a Dockable frame and their current state, usage, etc. Now the framework just lest the Window Manager resolve the issues like you have posed in your question above.
FYI ...
In order to have this type of control though in a PB2017Rx dockable application, you would have to adopt something like the above approach as the native PB run-time does not allow you that much control in this type of application style.
Regards ... Chris