Search code examples
windowsdelphianimationwindowaero

Windows Vista and 7 motion effects are applied only once when my form is shown. Why?


I created an application with two forms. First one is the main form and second one is hidden. I placed a button on Form1 and I made it ShowModal the second form. On Win7 the form appears with an animation. Then I close the appeared form (Form2) and I click the button once again. Form2 appears without the animation. I want the animation every time. What should I do?


Solution

  • The only thing I can think of right now is to create the form manually each time you want to display it modally. To do this, go to the project options and make sure that the form isn't automatically created. Then do

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      with TForm2.Create(self) do
        try
          ShowModal;
        finally
          Free;
        end;
    end;
    

    In my opinion, most often modal forms should in fact be created manually.