Background
In a standard modal dialog scenario, a user interacts with a Document Window
, causing a Modal Dialog Window
to appear. Three rules are enforced:
- Whilst
Modal Dialog Window
is visible, user interaction withDocument Window
is disabled. - Whilst
Modal Dialog Window
is visible, the OS prevents it from ever going behindDocument Window
in the Z-Order. - After
Modal Dialog Window
is dismissed, user interaction withDocument Window
becomes enabled once again.
In Xojo, this scenario is of course easy to set up, using Window.ShowModal
.
Problem
I need to display a Modal Dialog Window, exactly as described above, but with a crucial peculiarity:
In my specific case, Document Window
and Modal Dialog Window
will not be created by the same process.
There are project-specific technical reasons why this must be so, but for the purposes of this question, assume that Modal Dialog Window
will be created and handled by the child process of the process that creates and handles Document Window
.
Question
Can anyone outline how to achieve this on macOS? Or provide sample code which may help?
Note
Please see a working proof of concept solution for Windows 10. The following mechanisms allow it to work:
- Win32 function
EnableWindow
is used by the parent process to disableDocument Window
and again to reenable it at a later point - Win32 function
SetWindowLongPtr(self.handle,GWLP_HWNDPARENT,...)
is used by the child process to makeModal Dialog Window
an “owned” window ofDocument Window
. This works in Windows 10 even where the owned window is created by a different process to that of the owner window.