通俗的说:调用的函数(内部代码)需要使用自己编写的一个函数(外部代码) ,自己编写的<br>这个函数就是回调函数。<br><br>例子如下:(实现流动线的效果)<br><br>Timer1.Interval = 200;<br><br>var<br> Form1: TForm1;<br> Counter :Byte;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure MovingDots(X,Y: Integer; TheCanvas: TCanvas); stdcall;<br>begin<br> Counter := Counter shl 1; // Shift the bit left one<br> if Counter = 0 then Counter := 1; // If it shifts off left, reset it<br> if (Counter and 224) > 0 then // Are any of the left 3 bits set?<br> TheCanvas.Pixels[X,Y] :=clBtnFace // Erase the pixel<br> else<br> TheCanvas.Pixels[X,Y] :=clBlack; // Draw the pixel<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br> LineDDA(30,30,200,30,@MovingDots,LongInt(Canvas));<br> LineDDA(200,30,200,150,@MovingDots,LongInt(Canvas));<br> LineDDA(200,150,30,150,@MovingDots,LongInt(Canvas));<br> LineDDA(30,150,30,30,@MovingDots,LongInt(Canvas));<br>end;<br><br>以上的LineDDA就是我们说得内部函数,而它调用的MovingDots就是自己定义的外部函数,<br>也就是回调函数。<br><br>