Delphi application window z order and MainFormOnTaskBar property

旧时模样 提交于 2019-12-08 16:51:19

问题


I'm maintaining an application originally written in Delphi 7 and ported to Delphi XE.

Using Windows 7, we have experienced some problems like modal windows appearing under the main window and the eventual inability to interact with the program because the user is expected to interact with the modal form and that's impossible since it's under the main window.

To avoid this problem I changed the MainFormOnTaskBar property of the project to True (older projects don't have this property) and now I continue with the same project. Reading documentation I found the new Form property PopupParent. Is it mandatory to use this property if I set MainFormOnTaskBar to True? Is there another solution to this problem?


回答1:


Yes, for the modal forms that "pop-under", you have to fix the Z-order using PopupParent or PopupMode, as explained by Allen Bauer in his blog post PopupMode and PopupParent.

MainFormOnTaskBar documentation says it has little to do with the pop-under: it is for choosing where the Title/Icon information on the taskbar is obtained from (your Application or MainForm).

However, MainFormOnTaskBar := True does more and this article by Steve Trefethen (ex Delphi team member) explains many more details it in more detail.

This "more" has consequences involving z-order. Some you might like more or maybe less, so here are are a few examples:

  • the MainForm will be parent of new child windows which makes the Z-order of the MainForm always less than the child windows
  • like you observed, it fixes most of the z-ordering problems in Delphi <= 8 versions (if you want them back including modal dialogs potentially appearing under the main-form, then set MainFormOnTaskBar := False)
  • it enables some forms of docking like in the LMD components

Note that fighting the issues introduced with Vista were no small feat to solve as Microsoft introduced a lot more functionality but also took away some freedom applications used to have. Read these two articles by Nathanial Woolls to get a better impression on those.



来源:https://stackoverflow.com/questions/14280817/delphi-application-window-z-order-and-mainformontaskbar-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!