How to make sure a dialog is always front of the main window

送分小仙女□ 提交于 2019-12-03 17:16:45

From TCustomForm.PopupParent Property;

If the PopupMode property is set to pmExplicit and PopupParent is nil, then the Application.MainForm is implicitly used as the PopupParent

.

AFAIK Delphi 2007 support MainFormOnTaskbar feature. With

   Application.MainFormOnTaskbar := True;

in project source ANY application form (with default parent window) is shown above main form.


If you are unsure what form is the Main Form, go to Project/Options/Forms and set the correct Main Form. Another probable reason is that you are upgrading a project from a previous Delphi version so the project source does not contain the above line of code - add this line manually.

I think your first effort, fsstayontop, is the best option. The issue with displaying in front of other applications may be impossible to avoid since you are really using Windows function not something unique to Delphi.

As I recall it is possible to manually set the Z order, but that is tedious to impossible in most apps.

If your dialog is not so big as to hide other applications, it can be moved and users can still access the other apps without first interacting with your dialog. Seems not too bad.

You can try watching the OnHide event and immediately making the Visible flag to TRUE. This will probably cause flicker though.

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