如何获取不是主窗体的窗体的任务栏按钮? [英] How can I get taskbar buttons for forms that aren't the main form?

查看:96
本文介绍了如何获取不是主窗体的窗体的任务栏按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使表单出现在Delphi的任务栏上?在Firefox中,例如,当您在新窗口中打开页面时,它会在任务栏上创建另一个窗口,而不创建新的进程。目前我的Delphi应用程序在单击按钮时打开了一个新窗体,但任务栏上仍然只有一件事情,因此您无法在主窗体和当按钮为点击。如何更改它,以便新表单显示新的任务栏按钮?我现在的代码如下所示:

How do you make a form appear on the taskbar in Delphi? In Firefox, for example, when you open a page in a new window, it creates another window on the taskbar without creating a new process. At the moment my Delphi application opens a new form when a button is clicked, but there is still only one thing on the task bar, so you can't alt-tab between the main form and the form that is created when the button is clicked. How do I change it so that the new form appears with a new taskbar button? My current code looks like this:

procedure Form1ButtonClick(Sender: TObject);
begin
    Form2.Show;
end;

我一直在用$ code> CreateWindowEx 但是理想情况下,我想找到比直接使用Windows API更简单的解决方案。

I have been messing around with CreateWindowEx, but ideally I would like to find a simpler solution than directly using the Windows API.

推荐答案

如果我明白你想要什么,您可以通过覆盖它的CreateParams过程在任务栏上显示您的辅助表单,如最小化独立于主窗体的子窗体 delphi.about.com文章,如下所示:

If I understand what you want correctly, you can show your secondary forms on the task bar by overriding it's CreateParams procedure, as explained in Minimize child forms independent of the main form delphi.about.com article, like this:

interface

type
  TMyForm = class(TForm)
  ...
  protected
    procedure CreateParams(var Params: TCreateParams) ; override;
  ...

implementation

procedure TMyForm.CreateParams(var Params: TCreateParams) ;
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
  Params.WndParent := 0;
end;

这篇关于如何获取不是主窗体的窗体的任务栏按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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