如何使用使用createpolygonrgn和ptinregion函数(20分)

  • 主题发起人 主题发起人 顾捷
  • 开始时间 开始时间

顾捷

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在image中创建一个多边形区域,当我的鼠标点击该区域时旧响应一定的事件<br>检验鼠标是否在该区域旧用的是ptinregion,但问题是我用该两个函数时,只要我点击<br>image上的任何区域旧响应事件了,很奇怪!请指教具体谢,最好使用能用的原程序!
 
当鼠标在区域内,改变鼠标指针;否则,为默认.<br><br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls, ExtCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Image1: TImage;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,<br>&nbsp; &nbsp; &nbsp; Y: Integer);<br>&nbsp; &nbsp; procedure FormDestroy(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; FRgn :HRGN;<br>&nbsp; pt :array &nbsp;[0..3] of TPoint;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; pt[0] :=Point(50,100);<br>&nbsp; pt[1] :=Point(100,50);<br>&nbsp; pt[2] :=Point(150,100);<br>&nbsp; pt[3] :=Point(100,150);<br>&nbsp; Image1.Canvas.Polygon(pt);<br>&nbsp; FRgn :=CreatePolygonRgn(pt,4,Winding);<br>end;<br><br>procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,<br>&nbsp; Y: Integer);<br>begin<br>&nbsp; if PtInRegion(FRgn,x,y) then<br>&nbsp; &nbsp; Image1.Cursor :=crCross<br>&nbsp; else<br>&nbsp; &nbsp; Image1.Cursor :=crDefault;<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>&nbsp; DeleteObject(FRgn);<br>end;<br><br>end.
 
顾捷,我是dingyin,那个要画弧函数的:)<br>我的Email:dingyin@263.net<br>你有是能找到那段程序的话,麻烦寄给我,多谢了
 
接受答案了.
 
后退
顶部