Search code examples
delphimdi

Delphi Create Maximized MDI Child with AnimateWindow


I have an application with MDI forms, and i've been trying to make an Child creation effect, with Animatewindow().

My question is, all my MDI forms are with Windowstate=wsMaximized, and don't know how to create the form without showing the default classic window resize AND with the animation...

This is what i'm trying:

procedure FORMCREATOR(t_form:tformclass);
var form:tform;
begin
    frmain.sPanel5.Hide;
    frmain.LockClientWindowUpdate;    
    form:=t_form.Create(frmain);

// btw, if i do "t_form.Create(application)" instead of "t_form.Create(frmain);" it gives an error.. and with the "....(frmain)" i cant access the form like "form.button1.caption:='test'" outside this procedure, Access violation! .. help plox!

    frmain.UnlockClientWindowUpdate;  

    AnimateWindow(form.Handle,500,AW_CENTER or AW_SLIDE or AW_VER_POSITIVE); 
end;

So, when i call this, it just create the form like there was no Animatewindow()... it is only shown maximized with no effect :( ..

Guys please give me a little hand ! Thanks.


Solution

  • With @bummi 's idea..

    I changed to this:

    procedure tfrmain.FORMCREATOR(t_form:tformclass);
    var form:tform;
    nome_form:string;
    begin
        frmain.sPanel5.Hide;       
    
        frmain.lockClientWindowUpdate;
    
        With t_form.Create(frmain) do
        begin
             visible := false;
             Formstyle := fsNormal;   //Now i'll make all my forms as fsnormal  
             Parent := self;
    
             Width := frmain.sPanel5.width; 
             Height := frmain.sPanel5.height;       
             left:=frmain.sPanel5.left;
             top:=frmain.sPanel5.Top;
    

    //This Spanel5 is the supposed client area where will be the MDI child, thats why i hide it at the beggining of the procedure

             frmain.UnlockClientWindowUpdate;
    
             AnimateWindow(handle,1000, AW_CENTER or AW_SLIDE or AW_HOR_NEGATIVE );
    
             frmain.lockClientWindowUpdate;
    
             Parent := frmain;
             FormStyle := fsMDIChild;
             windowstate:=wsmaximized;
    
             frmain.unlockClientWindowUpdate;
        end;    
    end;
    

    And.... Yes ! It works perfectly, no image flickering and such things !! ;) Thanks a lot!