[Miscellaneous] The temporary processing method that the system dialog box (such as browsing the directory) is hidden behind the main window and the program cannot be operated
To be honest, I have been troubled by this problem for many years, and I have not found the specific reason until now. However, here is a temporary solution. Use a timer to check whether the active window of the current process is consistent with Screen.ActiveForm. If it is inconsistent, check whether Screen.ActiveForm is disabled (be careful not to look at its Enabled, but to call the API ), if it is disabled, it means that the pop-up dialog box is not a Delphi Form, we can call SetWindowPos to adjust it to the front display. The timer processing code is as follows:
1
2
3
4
5
6
7
8
|
procedure TForm1.Timer1Timer(Sender:TObject);
var
ATopWindow:THandle;
begin
ATopWindow:=GetActiveWindow;
if (ATopWindow<>Screen.ActiveForm.Handle) and (not IsWindowEnabled(Screen.ActiveForm.Handle)) then
SetWindowPos(ATopWindow,HWND_TOP,0,0,0,0,SWP_NOSIZE OR SWP_NOMOVE);
end;
|
This is a temporary solution for the symptoms. As for the root-cause solution, since the demo test alone cannot be reproduced in many cases, let's give it up for the time being, as a last resort...