Delphi 在应用程序运行时更改主窗体 [英] Delphi Change main form while application is running

查看:31
本文介绍了Delphi 在应用程序运行时更改主窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题.当我隐藏我的主窗体时,我的应用程序的任务栏图标也被隐藏了.我也看到了一个关于这个问题的新问题,但答案并没有真正帮助.他们建议最小化它,但我不想最小化应用程序.

I have this problem. When I hide my main form, then the taskbar icon of my application is also hidden. I saw a new question about this problem as well and the answers didn't really help. They suggested to minimize it, but I do not want to minimize the application.

是否可以在应用程序已经运行时更改主窗体?

Is it possible to change the main form while the application is already running?

例如.我有两种形式.当我想隐藏一个表单并显示另一个表单时,那么任务栏图标应该停留在任务栏并且主表单应该切换到另一个表单.

for instance. I have two forms. when I want to hide the one form and show the other form, then the taskbar icon should stay at the taskbar and the main form should switch to the other form.

我使用的是 Delphi XE6,它是一个 VCL Forms 应用程序.

I am using Delphi XE6 and it is a VCL Forms application.

我还看到了一个关于在运行时更改主窗体的不同老问题,但它已经很老了,仍然基于 Delphi 6.

I have also seen a different old question about changing main form while runtime, but it is very old and still based on Delphi 6.

推荐答案

是否可以在应用程序已经运行时更改主窗体?

Is it possible to change the main form while the application is already running?

在程序运行时无法更改 VCL 主窗体.该属性在程序启动时一劳永逸地确定.

It is not possible to change the VCL main form whilst the program is running. This property is determined once and for all when the program starts.

一种可能的方法是安排辅助窗体,即不是主窗体的窗体,在任务栏上有一个按钮.通过将其设为无主或使用 WS_EX_APPWINDOW 扩展窗口样式来实现.

One possible way to proceed for you is to arrange for the secondary form, the form that is not the main form, to have a button on the taskbar. Do that by making it unowned, or by using the WS_EX_APPWINDOW extended window style.

更新

好吧,您可以更改Application.MainForm,但这需要您销毁当前的主窗体,然后再创建一个新的主窗体.

Well, you can change Application.MainForm, but it requires you to destroy the current main form, and then create a new one.

这篇关于Delphi 在应用程序运行时更改主窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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