当鼠标在区域内,改变鼠标指针;否则,为默认.<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, ExtCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Image1: TImage;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,<br> Y: Integer);<br> procedure FormDestroy(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> FRgn :HRGN;<br> pt :array [0..3] of TPoint;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> pt[0] :=Point(50,100);<br> pt[1] :=Point(100,50);<br> pt[2] :=Point(150,100);<br> pt[3] :=Point(100,150);<br> Image1.Canvas.Polygon(pt);<br> FRgn :=CreatePolygonRgn(pt,4,Winding);<br>end;<br><br>procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,<br> Y: Integer);<br>begin<br> if PtInRegion(FRgn,x,y) then<br> Image1.Cursor :=crCross<br> else<br> Image1.Cursor :=crDefault;<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> DeleteObject(FRgn);<br>end;<br><br>end.