Mirror

MessageDlg hidden by main form (XP only) (Views: 711)

Problem/Question/Abstract:

When calling MessageDlg (and also on certain TForm forms on calling showModal) the dialog sometimes pops up under the main form, on Windows XP systems. This does not appear to affect other operating systems.

Answer:

Setting HKEY_CURRENT_USER\Control Panel\Desktop\ForegroundLockTimeout=0 seems to fix the problem... but WHY? According to MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/SetForegroundWindow.asp) the new window should be able to go to the foreground if the process is the foreground process. The process was started by the foreground process. The process received the last input event. There is no foreground process. The foreground process is being debugged. The foreground is not locked (see LockSetForegroundWindow). The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo). Windows 2000/XP: No menus are active.

Ok, well having checked the last point there, calling Application.ProcessMessages before popping up the dialog fixes the problem!

---
This solution taken from the DOMAJ forum: http://www.domaj.com/forum/viewthread.php?tid=348


<< Back to main page