主窗口最小化,其他非主窗口也一起最小化

主窗口最小化,其他非主窗口也一起最小化

楼主: 按照常理,程序的主窗口一旦最小化,该程序的其他所有非主窗口都要一起最小化。
特殊情况下,怎么实现非主窗口不受主窗口最小化的影响:即主窗口最小化了,其他非主窗口依然没有最小化。

----------------------------------------------
{ 注意:在 OnFormCreate 中调用有效! }
Winapi.Windows.SetParent(Self.Handle, FindWindowEx(FindWindow('Progman', nil),
0, 'shelldll_defview', nil));

可是,刚刚发现,有的时候,这个方法会失效。
明明设置非主窗口的父窗口为桌面了,并且在大多数情况下是可以成功,
但是为什么少数情况下失败呢 ?

继续测试。
----------------------------------------------

用CreateParams吧,例子如下:
unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm2 = class(TForm)
private
{ Private declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

{ TForm2 }

procedure TForm2.CreateParams(var Params: TCreateParams);
begin
inherited;

Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := GetDesktopWindow;
end;

end.
----------------------------------------------

5楼: 如果是 Win7 开了 AERO,并且窗口是半透明的话,要用SetWindowLong,不要用SetParent
----------------------------------------------

http://bbs.2ccc.com/topic.asp?topicid=515993

posted @ 2016-09-27 15:37  findumars  Views(586)  Comments(0Edit  收藏  举报