• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • Last Modified:

How can I create windows in cascating?

Hello guys

I developed a scheduler as outlook that can show me my compromises, when the day and time comes it appears on the windows showing me the text as outlook. My problem is when I have more than one booking, I would like to pop up all the windows in cascating style from my 0 top and left 0 increasing 20 or more pixel.
I need an example
Thanks
0
hidrau
Asked:
hidrau
  • 5
  • 2
  • 2
  • +1
2 Solutions
 
TNameCommented:
I'm not sure I understand your intention correctly. If you want to pop up several forms shifted horizontally and vertically e.g. by 20px each, you could try something like this (click Button1 to create and position the forms and Button2 to destroy them):


procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin
 for i:=0 to 10 do begin
    with TForm.Create(Self) do begin
       Name:='Frm'+IntToStr(i);
       Left:=Self.Left+i*20;
       Top:=Self.Top+i*20;
       Caption:=IntToStr(Left)+' '+IntToStr(Top);
       Show;
    end;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i:Integer;
f:TComponent;
begin
 for i:=0 to 10 do begin
    f:=FindComponent('Frm'+IntToStr(i));
    //ShowMessage(TForm(f).Caption);
    f.Free;
 end;
end;



If by startpoint 0 you mean 0px relative to the screen rather than to the main forn, just replace

       Left:=Self.Left+i*20;
       Top:=Self.Top+i*20;

with

       Left:=i*20;
       Top:=i*20;
0
 
mikelittlewoodCommented:
Is your application an MDI application?
If so you can use the cascadeWindows function.
0
 
mikelittlewoodCommented:
Sorry that should be

Cascade method (TForm)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
hidrauAuthor Commented:
no it is not a MDI application
0
 
sas13Commented:
procedure TForm1.Button1Click(Sender: TObject);
var
  _i, _inc: integer;
begin
 _inc := 0;
 for _i := 0 to Screen.FormCount-1 do
  with Screen.Forms[_i] do
   if Visible then begin
    SetBounds(_inc, _inc, Width, Height);
    BringToFront;
    Inc(_inc, 20)
   end
end;
0
 
hidrauAuthor Commented:
Hi Sas13

your solution was what I was looking for. Now, each form I created and it is in memory has in their tag a number sequence, is there any way to organize my forms according to sequence tag?

thanks
0
 
sas13Commented:
procedure TForm1.Button1Click(Sender: TObject);

 function SortList(AForm1, AForm2: TForm): integer;
 begin
  Result := CompareValue(AForm1.Tag, AForm2.Tag)
 end;

var
  _i, _inc: integer;
  _list: TList;
begin
 _list := TList.Create;
 try
  for _i := 0 to Screen.FormCount-1 do
   if Screen.Forms[_i].Visible then
    _list.Add(Screen.Forms[_i]);
  _list.Sort(@SortList);
  _inc := 0;
  for _i := 0 to _list.Count-1 do
   with TForm(_list[_i]) do begin
    SetBounds(_inc, _inc, Width, Height);
    BringToFront;
    Inc(_inc, 20)
   end;
 finally
  _list.Free
 end
end;
0
 
hidrauAuthor Commented:
CompareValue is a function created by you?
0
 
hidrauAuthor Commented:
ok, I found in math

0
 
hidrauAuthor Commented:
thanks very much for your help

TName, I also thank you for you help, part of your code I used.

:))
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now