이 문제의 경우, Stackoverflow에서 비슷한 질문을 통해 답을 찾아 냈습니다. 많은 도움이되었지만 문제를 해결하지 못했습니다. 내 프로그램은 다음과 같이 graphics.DrawLines 메서드를 사용하여 winform에 다각형을 그립니다.Graphics.DrawLines : 매개 변수가 유효하지 않습니다.
g.DrawLines(thepen,pts);
하지만 계속해서 "매개 변수가 유효하지 않습니다"라는 오류가 발생합니다. 그래서 나는 그 코드 라인을 다음과 같이 변경하여 어떤 차이가 있는지 확인했습니다.
g.DrawLines(new pen(color.Black),pts);
다시 동일한 오류가 발생합니다. pts는 system.drawing.point의 배열이고 thepen은 system.drawing.pen입니다.
완전히 주석 처리하면 프로그램에 오류가 발생하지 않습니다. 그러나 이상한 점은 지난 3 ~ 4 개월 동안 똑같은 코드를 사용해도 문제가 없다는 것입니다. 어제부터 다시 작동시키지 못합니다.
설정할 필요가있는 winform 속성 설정이 있습니까?
여기 UPDATE는
method TMakerPoly.Draw;
var
pts: Array of point;
i:integer;
theBrush1:HatchBrush;
theBrush2:SolidBrush;
begin
if (theBrushStyle = HatchStyle.Wave) then
theBrush1 := new HatchBrush(theBrushStyle,Color.Transparent,color.Transparent)
else if (theBrushStyle = HatchStyle.ZigZag) then
thebrush2 := new SolidBrush(FillColor)
else
theBrush1 := new HatchBrush(theBrushStyle,FillColor,color.Transparent);
if (thePen.DashStyle = DashStyle.Custom) then
thepen.Color := Color.Transparent;
pts := new point[pcount];
if pcount >= 2 then
begin
if Active then
begin
for i := 0 to pcount-1 do
pts[i] := point(points[i]);
Translate(var pts,pcount);
thepen.Color := EdgeColor(thepen.Color);
fillColor := self.BackColor(FillColor);
if visible then
begin
if filled then
begin
if theBrushStyle = HatchStyle.ZigZag then
g.FillPolygon(theBrush2,pts)
else
g.FillPolygon(thebrush1,pts);
g.DrawPolygon(thepen, pts);
end
else
g.DrawLines(thePen, pts);
end;
end
else
begin
for i := 0 to pcount-1 do
pts[i] := point(points[i]);
if filled then
begin
if theBrushStyle = HatchStyle.ZigZag then
g.FillPolygon(theBrush2,pts)
else
g.FillPolygon(thebrush1,pts);
g.DrawPolygon(thepen,pts);
end
else
g.DrawLines(new Pen(color.Black),pts);
end;
end;
end;
어떤 도움이나 힌트 혹은 힌트 크게 이해할 것이다 실제 연신 방법이다.
오류가 잘못된 매개 변수에 관한 것이면 변수 선언 및 매개 변수 ** 초기화로 코드를 실제로 게시해야합니다. 그들에 대한 모호한 설명은 유용하지 않습니다. –
'points'와'pcount'는 어디에서 왔는가? 여러분이 게시 한 코드에서 아무 곳에 나 선언되지 않았기 때문입니다. (여기에 도움이 필요하면 도움을 줄 정보를 제공해야합니다. 제공하지 않는 외부 변수에 의존하는 막연한 설명 및 코드는 전혀 유용하지 않습니다.) –
@KenWhite, 이러한 변수가 정의되어 있습니다. 동급에서. 'points'는 포인트의 arraylist이고, pcount는 arraylist의 포인트의 수입니다. – ThN