📄 readme.htm
字号:
<TD WIDTH="50%">Recalculate sizes, re-draw starting picture (or color).</TD>
</TR>
<TR>
<TD WIDTH="50%">UnBlend</TD>
<TD WIDTH="50%">This starts the transition using the Blend effect, but goes in
reverse order. It blends from either PicTo or ColorTo to PicFrom or
ColorFrom, depending on property settings.</TD>
</TR>
<TR>
<TD WIDTH="50%">UnDissolve</TD>
<TD WIDTH="50%">This starts the transition using the Dissolve effect, but goes
in reverse order. It dissolves from either PicTo or ColorTo to PicFrom or
ColorFrom, depending on property settings.</TD>
</TR>
</TABLE>
<P ALIGN="left"><BR>
<A NAME="Events"></A><STRONG>Events</STRONG></P>
<TABLE BORDER="1" WIDTH="50%">
<TR>
<TD WIDTH="50%"><STRONG>Event</STRONG></TD>
<TD WIDTH="50%"><STRONG>Description</STRONG></TD>
</TR>
<TR>
<TD WIDTH="50%">OnBegin</TD>
<TD WIDTH="50%">Fires when transition starts, by either a Blend or Disslove
method. </TD>
</TR>
<TR>
<TD WIDTH="50%">OnClick</TD>
<TD WIDTH="50%">Fires when user clicks on HarmFade. Use like a button
click.</TD>
</TR>
<TR>
<TD WIDTH="50%">OnEnd</TD>
<TD WIDTH="50%">Fires when transition is complete.</TD>
</TR>
<TR>
<TD WIDTH="50%">OnMouseDown </TD>
<TD WIDTH="50%">Fires when left mouse button is pressed.</TD>
</TR>
<TR>
<TD WIDTH="50%">OnMouseEnter</TD>
<TD WIDTH="50%">Fires when mouse enters HarmFade.</TD>
</TR>
<TR>
<TD WIDTH="50%">OnMouseLeave</TD>
<TD WIDTH="50%">Fires when mouse leaves HarmFade.</TD>
</TR>
<TR>
<TD WIDTH="50%">OnMouseUp </TD>
<TD WIDTH="50%">Fires when left mouse button is released.</TD>
</TR>
<TR>
<TD WIDTH="50%">OnReset</TD>
<TD WIDTH="50%">Fires when a Reset is done.</TD>
</TR>
</TABLE>
<P ALIGN="left"><BR>
<A NAME="Examples"></A><STRONG>Examples<BR>
</STRONG>When a THarmFade is dropped on a form (or panel, etc), it will just be
a small black box. It will function without loading any pictures, but is
much more effective if PicFrom and/or PicTo is assigned. Just
double-click one of those properties in the Object Inspector to load an image,
much like a TImage. To start the transition, you must use the Blend or
Disslove method in your application code:<BR>
<BR>
<FONT FACE="Courier New">procedure TForm1.Button1Click(Sender: TObject);<BR>
begin<BR>
HarmFade1.Dissolve;<BR>
{or}<BR>
HarmFade1.Blend;<BR>
end;<BR>
</FONT><BR>
If neither the From or To Picture has been assigned, it will transition from a
'ColorFrom' square to a 'ColorTo' square.<BR>
<BR>
After completing the transition, the PicTo (or ColorTo) will remain visible
unless<BR>
AutoReverse is True, or until either:<BR>
1) the effect is started again with .Dissolve or .Blend, or<BR>
2) the THarmFade.Reset method is used. This will reset the pictures back to
their 'original' state, prior to transition. Changing any of the following
properties will also cause the Reset method to be called:<BR>
PicFrom, PicTo, ColorFrom, ColorTo, or StretchToFit.<BR>
<BR>
If only one of PicFrom or PicTo is assigned, the transition will use a solid
color for the other picture. For example, if PicFrom is<BR>
assigned, and PicTo is not, then the ColorTo color will be used instead of
PicTo.<BR>
<BR>
If PicFrom or PicTo is a MetaFile or Icon, they support transparency. The
background color will be the ColorFrom or ColorTo, respectively.<BR>
<BR>
StretchToFit by default is True. When a picture is assigned, it will
StretchDraw it to fit into the current size of HarmFade. If StretchToFit
is False, then the HarmFade is sized to match the PicFrom picture (if assigned)
and the PicTo is stretched to match that size. If PicFrom is empty, the
HarmFade will be sized based on PicTo. In order for the fading effect to
work, the From and To pictures must be made the same size. I didn't want to
force people to size the pictures prior to using this control, so I made up
these rules. Again, some experimentation with the pictures and this setting
will give you a better feel for how it all works.<BR>
<BR>
ProcessMessages is FALSE by default. The HarmFade uses tight loops for doing
the animation, which means your application is locked until it's complete . You
can't use buttons, scrollbars, etc in your application until the .Blend or
.Dissolve method has completed. Setting the ProcessMessages property to
TRUE allows the animation to be interrupted. It allows the tight loop to be
paused for handling other tasks. The animation stops while messages are
processed, then continues when it can.<BR>
<BR>
While this all may sound complicated, it's really quite easy to use HarmFade:
Drop a THarmFade on a form. Double Click the PicFrom property, and use the
Dialog to select a graphic supported by tpicture. Double Click the PicTo
property and select a different picture. (Or leave one of these
properties unassigned). Add a TButton to your form, and add the following line
to the OnClick:<BR>
<BR>
<FONT FACE="Courier New">HarmFade1.Dissolve;</FONT><BR>
<BR>
Run the program, then click the button. Watch the dissolve, and adjust the
DisolvRate property as desired for maximum effect. To unassign one of the
bitmap properties, double click the property and use the Clear button in the
dialog. To achieve the same effect in code, use this:<BR>
<BR>
<FONT FACE="Courier New">HarmFade1.PicTo := nil;</FONT></P>
<P ALIGN="left">You can use HarmFade as a crude button, but with interesting
effects. Use your favorite Paint program to design a picture that looks
like a button, with very dark colors, or just solid black with gray text (for
the 'caption'). Save it, then flood fill the text with a bright color
(like red or lime) and save it as a different filename. Use these as the
PicFrom and PicTo, respectively. Then, in your application, add the
following code:</P>
<P ALIGN="left"><SMALL><FONT FACE="Courier New">procedure
TForm1.HarmFade1MouseEnter(Sender: TObject);<BR>
begin<BR>
HarmFade1.Blend;<BR>
end;<BR>
</FONT><BR>
<FONT FACE="Courier New">procedure TForm1.HarmFade1MouseLeave(Sender: TObject);
<BR>
begin<BR>
HarmFade1.UnBlend;<BR>
end;</FONT></SMALL></P>
<P ALIGN="left"><SMALL><FONT FACE="Courier New">procedure
TForm1.HarmFade1Click(Sender: TObject);<BR>
begin<BR>
ShowMessage('You clicked on HarmFade');<BR>
end;<BR>
</FONT></SMALL><BR>
When the mouse moves over the HarmFade, it will start the blend
transition. When the mouse leaves the HarmFade, it will UnBlend back to
the original image.</P>
<P ALIGN="left">You may want to have this Transition effect take place whenever
a Form is first shown. This can be achieved by placing the .Dissolve or .Blend
method in the form's OnShow event. However, it seems that the transition starts
up before the form is completely painted. Thanks to Anders Melander and Joachim
Meyer for advice on how to surmount this problem:<BR>
<BR>
*** Add a user message constant (MY_MSG)<BR>
*** Add a procedure to handle message (MY_MSG)<BR>
*** In Form's OnShow event, Post the new message<BR>
*** In the new message handler, do the animation<BR>
<BR>
<SMALL><FONT FACE="Courier New">unit Unit1;<BR>
<BR>
interface<BR>
<BR>
uses<BR>
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,<BR>
Dialogs, StdCtrls, HarmFade;<BR>
<BR>
const<BR>
MY_MSG = WM_USER + 1; {<=== Add this}<BR>
<BR>
type<BR>
TForm1 = class(TForm)<BR>
Label1: TLabel;<BR>
HarmFade1 : THarmFade;<BR>
procedure FormShow(Sender: TObject); {<== Add code to OnShow}<BR>
....<BR>
private<BR>
procedure WeArePainted(var Msg : TMessage); message MY_MSG;<BR>
.... {== Add the above procedure ==}<BR>
<BR>
implementation<BR>
<BR>
procedure TForm1.FormShow(Sender: TObject);<BR>
begin<BR>
PostMessage(Handle, MY_MSG, 0, 0); {<== Post our new message}<BR>
end;<BR>
<BR>
{== The following procedure now gets control once form is painted}<BR>
procedure TForm1.WeArePainted(var Msg : TMessage);<BR>
begin<BR>
Application.ProcessMessages;<BR>
HarmFade1.Dissolve;<BR>
end;<BR>
</FONT></SMALL><BR>
How to make a Splash Screen with a THarmFade component<BR>
<BR>
Here's an example of using a splash screen, with a THarmFade transition method
thrown in:<BR>
<BR>
First, design your splash screen form. I modify the form's border property to
bsNone to get rid of the title bar. I also make the form's ClientWidth and
ClientHeight match the HarmFade1.Width and Height. I would then change the
Position to poScreenCenter to make sure it centers in the screen at run-time.
Of course, this is all arbitrary.<BR>
Assuming you gave the form a name of fSplash....<BR>
<BR>
In the project source code (from the menu, select Project, View Source), make
the following modifications:<BR>
<BR>
***Add Windows to the uses clause.<BR>
***Add a variable before the begin statement, for your splash form.<BR>
***Create your form and show it before creating the other form(s).<BR>
***Add the Harmfade.Blend prior to creating other forms.<BR>
Here's an example:<BR>
<BR>
<SMALL><FONT FACE="Courier New">program Project1;<BR>
<BR>
uses<BR>
Windows, Forms, <== Add 'Windows' for Sleep()<BR>
Unit1 in 'Unit1.pas' {Form1},<BR>
Splash in 'Splash.pas' {fSplash};<BR>
<BR>
{$R *.RES}<BR>
<BR>
var<BR>
Splasher : TfSplash; <== Add var for splash form<BR>
<BR>
begin<BR>
try<BR>
Splasher := TfSplash.Create(Application); <== Create form
<BR>
Splasher.FormStyle := fsStayOnTop; <== Stay on Top<BR>
Splasher.Show; <== Show form <BR>
Sleep(1000); <== Delay 1 second<BR>
Splasher.HarmFade1.Dissolve; <== Do dissolve<BR>
Sleep(5000); <== Delay 5 secs<BR>
Application.Initialize; <BR>
Application.CreateForm(TForm1, Form1);<BR>
//Application.CreateForm(TfSplash, fSplash); <==Remove
<BR>
Splasher.Close; <== Close splash<BR>
finally<BR>
Splasher.Free; <== Free resources<BR>
end;<BR>
Application.Run;<BR>
end.<BR>
</FONT></SMALL><BR>
See the accompanying Demo for more coding examples.<BR>
<BR>
** To make a Harmfade blend from it's underlying form/controls:<BR>
<BR>
Similar to the splash example. Place a Harmfade on your form and set the
Visible property to FALSE. Set the PicTo picture to whatever.<BR>
* Note - if underlying controls are windowed controls (memo, button, etc) there
is a bit of flicker when harmfade effect starts.<BR>
The following example uses a couple of buttons to start and stop the effect:
<BR>
<BR>
<SMALL><FONT FACE="Courier New">procedure TForm1.Button1Click(Sender: TObject);
<BR>
var<BR>
ADC : HDC;<BR>
sx, sy : integer;<BR>
bm : TBitmap;<BR>
begin<BR>
ADC := GetDC(0);<BR>
bm := TBitmap.Create; //Need a temporary bitmap.<BR>
bm.Width := HarmFade1.Width;<BR>
bm.Height := Harmfade1.Height;<BR>
sx := HarmFade1.ClientOrigin.x; <BR>
sy := HarmFade1.ClientOrigin.y;<BR>
Bitblt(bm.Canvas.Handle, 0, 0, //BitBlt to our temp bmp<BR>
bm.Width, bm.Height,<BR>
ADC, sx, sy, SRCCOPY);<BR>
HarmFade1.PicFrom.Assign(bm); //Assign it to harmfade<BR>
//IF harmfade covers other controls, it's best to make them<BR>
// invisible here, like Image1.Visible := FALSE;<BR>
HarmFade1.Visible := TRUE; // Sneak us into position<BR>
HarmFade1.Blend; // Show the PicTo<BR>
bm.Free; // Free the temp bmp<BR>
end;<BR>
<BR>
procedure TForm1.Button2Click(Sender: TObject);<BR>
begin<BR>
HarmFade1.Visible := FALSE;<BR>
//If other controls were made invisible, reverse it<BR>
// here Image1.Visible := TRUE;<BR>
end;<BR>
</FONT></SMALL><BR>
<BR>
<BR>
</P>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -