首页  编辑  

如何排列多个窗口

Tags: /超级猛料/API.Windows应用程序接口/窗口和控件相关/   Date Created:

对打开的多个窗口进行有序的排列

来自: lanbei, 时间: 2005-02-21 13:55:00, ID: 2993118  

在一个应用程序中,要同时打开多个窗口.怎样在程序中实现呀?

来自: Kingron, 时间: 2005-03-09 11:52:20, ID: 3008692  

function CascadeWindowsEx(const Owner: HWND; const R: TRect; const WinHWNDs : array of HWND): Integer;

var

OldParent: array of HWND;

i : integer;

begin

SetLength(OldParent, Length(WinHWNDs));

for i:=Low(OldParent) to High(OldParent) do

begin

  OldParent[i] := GetParent(WinHWNDs[i]);

  Windows.SetParent(WinHWNDs[i], Owner);

end;

Result := CascadeWindows(Owner, MDITILE_SKIPDISABLED, @R, Length(WinHWNDs), @WinHWNDs[0]);

/// Restore

for i:=Low(OldParent) to High(OldParent) do

  Windows.SetParent(WinHWNDs[i], OldParent[i]);

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

CascadeWindowsEx(Handle, BoundsRect, [Form2.Handle, Form3.Handle, Form4.Handle]);

end;

procedure TForm1.FormShow(Sender: TObject);

begin

Form2.Show;

Form3.Show;

Form4.Show;

//  Windows.SetParent(Form2.Handle, Handle);

//  Windows.SetParent(Form3.Handle, Handle);

//  Windows.SetParent(Form4.Handle, Handle);

end;