为什么 Setlength 不能正常工作?! (0分)

  • 主题发起人 主题发起人 ddev
  • 开始时间 开始时间
D

ddev

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);<br>const<br>&nbsp; POINT_COUNT = 6;<br>var<br>&nbsp; pts: array of TPoint;<br>&nbsp; hpn: HPEN;<br>begin<br>&nbsp; SetLength(pts, POINT_COUNT);<br><br>&nbsp; pts[0] := Point(10, 10);<br>&nbsp; pts[1] := Point(100, 10);<br>&nbsp; pts[2] := Point(100, 20);<br>&nbsp; pts[3] := Point(10, 20);<br>&nbsp; pts[4] := Point(10, 30);<br>&nbsp; pts[5] := Point(100, 30);<br>&nbsp; <br>&nbsp; hpn := GetStockObject(BLACK_PEN);<br>&nbsp; SelectObject(Canvas.Handle, hpn);<br>&nbsp; PolyLine(Canvas.Handle, pts, POINT_COUNT);<br>&nbsp; DeleteObject(hpn);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>const<br>&nbsp; POINT_COUNT = 6;<br>var<br>&nbsp; pts: array[0..POINT_COUNT - 1] of TPoint;<br>&nbsp; hpn: HPEN;<br>begin<br>&nbsp; pts[0] := Point(10, 10);<br>&nbsp; pts[1] := Point(100, 10);<br>&nbsp; pts[2] := Point(100, 20);<br>&nbsp; pts[3] := Point(10, 20);<br>&nbsp; pts[4] := Point(10, 30);<br>&nbsp; pts[5] := Point(100, 30);<br><br>&nbsp; hpn := GetStockObject(BLACK_PEN);<br>&nbsp; SelectObject(Canvas.Handle, hpn);<br>&nbsp; PolyLine(Canvas.Handle, pts, POINT_COUNT); <br>&nbsp; DeleteObject(hpn);<br>end;<br><br>第二个函数能够正常处理,但第一个函数却不能:why?
 
还得看TPoint的定义才能确定
 
&nbsp;PolyLine(Canvas.Handle, pchar(@pts[0])^, POINT_COUNT);
 
&nbsp;PolyLine(Canvas.Handle, pts[0], POINT_COUNT);
 
xiao_min的方法是对的!
 
接受答案了.
 

Similar threads

I
回复
0
查看
465
import
I
I
回复
0
查看
717
import
I
I
回复
0
查看
874
import
I
后退
顶部