如何最小化任务栏窗口? (即未图标化) [英] How to minimize a window to the taskbar? (i.e. not iconify)

查看:225
本文介绍了如何最小化任务栏窗口? (即未图标化)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要最小化的窗口(到任务栏),所以我叫 ShowWindow

  ShowWindow(Handle,SW_MINIMIZE); 

除了不是将自身最小化(到任务栏),该窗口是 iconized em>:





该窗口是非父窗口:





如何最小化任务栏窗口?






更新:



。 p>

但这不应该影响这个问题。我正在调用 ShowWindow(...,SW_MINIMIZE) API,而不是最小化Windows正在图标化应用程序的窗口。



如何最小化任务栏窗口?

解决方案

该图标



使用:



<$ p任务栏是应用程序(句柄)的图标,而不是MainForm的图标。 $ p> Application.Minimize;

编辑:但是在您的两个链接中,我知道您知道已经... duh;)



这适用于MainForm:

  TForm1 = class(TForm)
private
过程WMSysCommand(var Msg:TWMSysCommand);消息WM_SYSCOMMAND;
受保护的
过程CreateParams(var Params:TCreateParams);覆盖

...

过程TForm1.CreateParams(var Params:TCreateParams);
开始
继承了CreateParams(Params);
与Params一起执行
开始
ExStyle:= ExStyle或WS_EX_APPWINDOW;
WndParent:= GetDesktopWindow;
结尾;
结尾;

过程TForm1.WMSysCommand(var Msg:TWMSysCommand);如果Msg.CmdType = SC_MINIMIZE,则
开始
,然后
ShowWindow(Handle,SW_MINIMIZE)
其他
继承;
结尾;

并从任务栏隐藏Application.Handle(只对MainForm有一个任务栏图标):将此窗体的 Visible 属性设置为 True 并将应用程序隐藏在项目文件中:

  Application.Initialize; 
Application.CreateForm(TForm1,Form1);
ShowWindow(Application.Handle,SW_HIDE);
Application.Run;

对于此表单, ShowWindow(Handle,SW_MINIMIZE); 应该工作。



(在XP和W7的D5和D7上进行了测试)


i have a window that i want to minimize (to the taskbar), so i call ShowWindow:

ShowWindow(Handle, SW_MINIMIZE);

Except that rather than minimizing itself (to the taskbar), the window is iconified:

The window is unparented:

How do i minimize a window to the taskbar?


Update:

Following some advice from 2002, i try setting the WS_EX_APPWINDOW window style and/or ensuring the window has no owner:

Unfortunately, that changes the behavior of my (Delphi) application because there is now two taskbar icons for my application, rather than one:

This, of course, is an artifact of Delphi (5); and because i was trying to solve another issue.

But that shouldn't affect this question. i'm calling the ShowWindow(..., SW_MINIMIZE) API, and rather than minimize the window Windows is iconifying the application.

How do i minimize a window to the taskbar?

解决方案

That icon on the taskbar is the icon of the Application (Handle) rather than that of the MainForm.

Use:

Application.Minimize;

Edit: But out of both your links, I understand you knew that already...duh ;)

This works for the MainForm:

TForm1 = class(TForm)
private
  procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
protected
  procedure CreateParams(var Params: TCreateParams); override;

...

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
  begin
    ExStyle := ExStyle or WS_EX_APPWINDOW;
    WndParent := GetDesktopWindow;
  end;
end;

procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
  if Msg.CmdType = SC_MINIMIZE then
    ShowWindow(Handle, SW_MINIMIZE)
  else
    inherited;
end;

And to hide Application.Handle from the taskbar (to only have a taskbar icon for the MainForm): set the Visible property of this Form to True and hide the Application in the project file:

Application.Initialize;
Application.CreateForm(TForm1, Form1);
ShowWindow(Application.Handle, SW_HIDE);
Application.Run;

For this form, ShowWindow(Handle, SW_MINIMIZE); shóuld work. It also provides for the default zooming-feature of Windows when minimizing or restoring.

(Tested with D5 & D7 on XP and W7)

这篇关于如何最小化任务栏窗口? (即未图标化)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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