Jump to content

Tiling/cascading Windows Algorithm


Recommended Posts

I am working on a TaskList Docklet which tries to replicate as much as possible the behaviour of the windows taskbar... I am trying to implement the Cascading/stacking of windows that is done via rigth-clicking on an empty area of the Task bar.

Does anyone knows how windows does this? I believe it should use BeginDeferWindowPos/DeferWindowPos/EndDeferWindowPos API calls to reposition all windows simultaneously. First, I was not able to find any conde sample that actually uses them... on the other hand, it stills elude me the actual algorithms used by the taskbar to calculate the new window position of the different shown windows. Does anyone kowns any info on this... I have googled a lot but only found info on MDI child forms.

Thanks.

Link to comment

Maybe you can also try using the Windows Shell Object, I don't know how to do that with Visual but here an example for Delphi:

unit Unit1;

interface

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

type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
CascadeWindows1: TMenuItem;
ileWindowsHorizontally1: TMenuItem;
ileWindowsVertically1: TMenuItem;
ShowtheDesktop1: TMenuItem;
UndoMinimizeAll1: TMenuItem;
Show1: TMenuItem;
procedure CascadeWindows1Click(Sender: TObject);
procedure UndoMinimizeAll1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ileWindowsHorizontally1Click(Sender: TObject);
procedure ileWindowsVertically1Click(Sender: TObject);
procedure ShowtheDesktop1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
shell: OleVariant;
implementation

uses ComObj;

{$R *.dfm}

procedure TForm1.CascadeWindows1Click(Sender: TObject);
begin
shell.CascadeWindows;
end;

procedure TForm1.UndoMinimizeAll1Click(Sender: TObject);
begin
shell.UndoMinimizeAll;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
shell:=CreateOleObject('Shell.Application');
end;

procedure TForm1.ileWindowsHorizontally1Click(Sender: TObject);
begin
shell.TileHorizontally
end;

procedure TForm1.ileWindowsVertically1Click(Sender: TObject);
begin
shell.TileVertically
end;

procedure TForm1.ShowtheDesktop1Click(Sender: TObject);
begin
shell.MinimizeAll
end;

end.

Link to comment

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...