多个Delphi应用程序和对话框 [英] Multiple form Delphi applications and dialogs

查看:239
本文介绍了多个Delphi应用程序和对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Delphi 7应用程序,它具有文档的两个视图(例如,所见即所得的HTML编辑可能具有所见即所得的视图和源视图 - 而不是我的实际应用)。它们可以在单独的窗口中打开,或者停靠在主窗口中的选项卡中。

I have a Delphi 7 application that has two views of a document (e.g. a WYSIWYG HTML edit might have a WYSIWYG view and a source view - not my real application). They can be opened in separate windows, or docked into tabs in the main window.

如果我从其中一个单独的窗体打开一个模态对话框,主窗体将被带入到前面,并在Windows任务栏中显示为所选窗口。说主图是所见即所得的视图,源视图被弹出。您可以在源视图中的特定点插入图像标签。出现一个对话框,允许您选择并输入图像所需的属性。如果WYSIWYG视图和源视图重叠,则所见即所得视图将被显示在前面,并且源视图被隐藏。一旦对话框被关闭,源视图就可以看到。

If I open a modal dialog from one of the separate forms, the main form is brought to the front, and is shown as the selected window in the windows taskbar. Say the main form is the WYSIWYG view, and the source view is poped out. You go to a particular point in the source view and insert an image tag. A dialog appears to allow you to select and enter the properties you want for the image. If the WYSIWYG view and the source view overlap, the WYSIWYG view will be brought to the front and the source view is hidden. Once the dialog is dismissed, the source view comes back into sight.

我已经尝试将所有者和ParentWindow属性设置为与之相关的形式:

I've tried setting the owner and the ParentWindow properties to the form it is related to:

dialog:= TDialogForm.Create(parentForm);

dialog.ParentWindow:= parentForm.Handle;

如何解决这个问题?我还应该尝试什么?

How can I fix this problem? What else should I be trying?

鉴于人们似乎绊倒了我的例子,也许我可以尝试一个更好的例子:一个文本编辑器,让你有同时打开多个文件。您打开的文件位于选项卡(如Delphi IDE中)或其自己的窗口中。假设用户打开拼写检查对话框或查找对话框。会发生什么,如果文件正在自己的窗口中编辑,那么当显示模态对话框时,该窗口将以z顺序发送到主窗体的下方;一旦对话框关闭,它将返回到原来的z顺序。

Given that people seem to be stumbling on my example, perhaps I can try with a better example: a text editor that allows you to have more than one file open at the same time. The files you have open are either in tabs (like in the Delphi IDE) or in its own window. Suppose the user brings up the spell check dialog or the find dialog. What happens, is that if the file is being editing in its own window, that window is sent to below the main form in the z-order when the modal dialog is shown; once the dialog is closed, it is returned to its original z-order.

注意:如果您使用的是Delphi 7并寻找解决这个问题,看到我的答案低于页面,看看我最后做了什么。

Note: If you are using Delphi 7 and looking for a solution to this problem, see my answer lower down on the page to see what I ended up doing.

推荐答案

我会用这个代码...(基本上是Lars说的)

I'd use this code... (Basically what Lars said)

dialog := TDialogForm.Create( parentForm );
dialog.PopupParent := parentForm;
dialog.PopupMode   := pmExplicit; 
dialog.ShowModal();

这篇关于多个Delphi应用程序和对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆