Q: I do not understand now, even think the main CB window can not be animated effect. Because the button on the task bar represents a application window, not the MainForm selected by project. If forced to mainform dynamically minimize, it will be minimized to the lower left corner of the desktop.
For:
I basically agree with you. The main window in Delphi & BCB is tapplication, in general, this window resides in the middle of the screen and is 0x0 in size. buttons on the bottom taskbar
is also the Tapplication window. The application's main window, such as TForm1, is not a Tapplicaiton child window, but he does not have the Ws_ex_appwindow attribute, so the Button is not generated on the taskbar. When minimized, because the Tapplication window is 0x0, so if the dynamic will be very difficult to see, so the VCL in the SystemParametersInfo API so that the Tapplication window is not moved when minimized. As for TForm1, because the button on the bottom taskbar is not his, so vcl directly hide TForm1. In this way, it makes the whole look like it's not moving.
The following code can be found in the VCL source Forms.pas:
Procedure Tapplication.minimize;
Begin
If not isiconic (Fhandle) Then
Begin
normalizetopmosts;
SetActiveWindow (Fhandle);
Showwinnoanimate (Fhandle, sw_minimize);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If assigned (fonminimize) then fonminimize (Self);
End
End
Procedure Tapplication.restore;
Begin
If Isiconic (Fhandle) Then
Begin
SetActiveWindow (Fhandle);
Showwinnoanimate (Fhandle, Sw_restore);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{following omitted}
End
Take another look at Showwinnoanimate:
Procedure Showwinnoanimate (Handle:hwnd; Cmdshow:integer);
Var
Animation:boolean;
Begin
Animation: = getanimation;
If Animation then Setanimation (False); (1)
^^^^^^^^^^^^^^^^^^^^^
ShowWindow (Handle, cmdshow);
If Animation then Setanimation (True);
End
Take another look at Setanimation:
Procedure Setanimation (Value:boolean);
Var
Info:tanimationinfo;
Begin
Info.cbsize: = SizeOf (Tanimationinfo);
BOOL (info.iminanimate): = Value;
SystemParametersInfo (Spi_setanimation, SizeOf (Info), @Info, 0);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Originally here.
End
Let's see what he does when TForm1 is going to minimize. Because Tform is from Tcustomform
Inherited over, he himself did not respond to the Wm_syscommand method, so the use was
Tcustomform's.
Procedure Tcustomform.wmsyscommand (var message:twmsyscommand);
Begin
if (Message.cmdtype and $FFF 0 = sc_minimize) and
(Application.mainform = Self) Then
Application.minimize
^^ ^^ ^^ ^^ ^^ ^^ the ^^ ^^ ^^ The execution of this sentence minimizes the tapplication, hiding
Form1.
Else
inherited;
End
You can comment out the above (1) sentence, you will find the tapplication minimized when the move, but
It's hard to see.
Oh, there's one solution for the following:
The first is to use SetWindowLong to turn Form1 into Ws_ex_appwindow, but the old must
Hides the application window. Use of ShowWindow (application.handle,sw_hide);
We must also change the source code of VCL. In the Forms.pas, the top of the Tcustomform.wmsyscommand
Comment out if, leaving only inherited, so that the Form1 will not be killed when the old application
of the window again. The specific change method is as follows.
1. Copy a forms.pas to the current directory and remove the default forms cell from project source.
Then add Forms.pas as a new unit into project.
2. Change project source as follows:
Program Project1;
Uses
Windows
^^^^^^^^^
Unit1 in ' Unit1.pas ' {Form1},
Forms in ' Forms.pas ';
{$R *. RES}
Begin
Application.initialize;
Application.createform (TForm1, Form1);
SetWindowLong (Form1.handle,gwl_exstyle,getwindowlong (Form1.handle,
Gwl_exstyle) or Ws_ex_appwindow);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Form1.show;
^^^^^^^^^^^
ShowWindow (Application.handle,sw_hide);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Application.Run;
End.
All of the above hits ^ are added code.
3. Change the Tcustomform.wmsyscommand in Forms.pas to the following:
We can also try the effect of not changing.
Procedure Tcustomform.wmsyscommand (var message:twmsyscommand);
Begin
{if (Message.cmdtype and $FFF 0 = sc_minimize) and
(Application.mainform = Self) Then
Application.minimize
else}--------------------------------commented out.
inherited;
End
With the above steps, basically the old can achieve animation scaling.
BTW: This method of implementation also has a certain flaw, that for the Big Gorge has a better way please propose to
For everyone to communicate.