々
々飞翔鸟々
Unregistered / Unconfirmed
GUEST, unregistred user!
我在Form上加了一个Image控件并Load了一副图象,请问如何OnMouseDown在图象上,而获得在Form上的坐标(X,Y)?<br>procedure TfrmChina.FormMouseDown(Sender: TObject; Button: TMouseButton;<br> Shift: TShiftState; X, Y: Integer);<br>begin<br> if Button=mbRight then<br> begin<br> if id<>1 then //画出起点<br> begin<br> frmChina.Canvas.Pen.Color:=clred;<br> frmChina.Canvas.Pen.Style:=psDash;<br> frmChina.Canvas.Pen.Width:=10;<br> frmChina.Canvas.MoveTo(x,y);<br> frmChina.Canvas.LineTo(x,y);<br> id:=1;<br> end<br> else begin //画出第二点并连线<br> frmChina.Canvas.Pen.Color:=clblue;<br> frmChina.Canvas.Pen.Style:=psDash;<br> frmChina.Canvas.Pen.Width:=3;<br> frmChina.Canvas.LineTo(x,y);<br> frmChina.Canvas.Pen.Color:=clred;<br> frmChina.Canvas.Pen.Style:=psDash;<br> frmChina.Canvas.Pen.Width:=10;<br> frmChina.Canvas.MoveTo(x,y);<br> frmChina.Canvas.LineTo(x,y);<br><br> cx:=x;<br> cy:=y;<br> end;<br> end;<br>end;<br><br>在form上没有问题<br>但是在image上时候偏移量很大<br>请问怎么转换坐标啊<br>最好给出源码,谢谢