I have the following problem: we are creating a rather large application (win32, Delphi 6 Enterprise). Several parts of the application use modal windows, usually containing the detail of selecting the main window.
We have included a modification to the processing of WM_SYSCOMMAND messages, so that if the window is modal, then the SW_SHOWMINNOACTIVE message will be sent to the main application window. This leads to minimization of the entire application, and not just to the modal form.
However, in a specific case, a problem arises: if the calling window is set to full screen, then when recovering, a modal window appears under the maximum (disabled) main window (this seems to be happening in Windows 7)
My problem is double:
Firstly, I don’t get the syscommand message when the application is being restored, so I can’t enter the Z-Order recovery code because I don’t know where to put it. Secondly, it seems to me that if the entire application is minimized, clicking on the application button on the taskbar should restore it to the same state, and not under the modal window. Is there any way to fix this?
Edit: we did some additional testing, and it looks like we can actually detect the problem in the WM_ACTIVATE handler for the main form. We can also define a modal window at this stage. However, I cannot find a way to restore it at the top of the Z-Order.
Edit2: here is the code that minimizes the application when the modal form is minimized:
procedure TfmGITForm.WMSysCommand(var Message: TWMSysCommand); begin if (fsModal in FormState) or not Application.MainForm.Visible then begin case Message.CmdType of SC_MINIMIZE: begin ShowWindow(Application.Handle, SW_SHOWMINNOACTIVE); end; SC_RESTORE: begin ShowWindow(Application.Handle, SW_SHOWNORMAL); inherited; end; else inherited; end; // case end else inherited; end;
All our forms come off this.