all groups > dotnet interop > october 2005 >
You're in the

dotnet interop

group:

Can't find the problem with gdi32 import


Can't find the problem with gdi32 import Softimax
10/25/2005 6:27:17 PM
dotnet interop:
The following code contains a mistake, but I can't find it.
Polyline works ok and PolyPolyline doesn't draw. Why?
Thanks!


[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int x;
public int y;
}



[DllImport("gdi32")] public static extern int PolyPolyline(IntPtr hdc,
POINT [] lppt, int [] lpdwPolyPoints, int cCount);
[DllImport("gdi32")] public static extern int Polyline(IntPtr hdc,
POINT[] lppt, int cCount);


IntPtr hDC = g.GetHdc();
POINT [] Points = new Win32.POINT[3];
int [] Lenghts = new int[1];

Points[0].x = 0;
Points[0].y = 0;
Points[1].x = 100;
Points[1].y = 30;
Points[2].x = 100;
Points[2].y = 100;
Lenghts[0] = 3;
PolyPolyline(hDC, Points, Lenghts, 3);

Points[1].x = 40;
Points[1].y = 90;
Polyline(hDC, Points, 3);
g.ReleaseHdc( hDC );
Re: Can't find the problem with gdi32 import Doug Forster
10/26/2005 12:00:00 AM
Try this:

PolyPolyline(hDC, Points, Lenghts, 1);

Better still: check the return code for errors

Cheers
Doug Forster

[quoted text, click to view]

Re: Can't find the problem with gdi32 import Softimax
11/3/2005 3:15:41 PM

Doug Forster ha scritto:

[quoted text, click to view]

I try and i get ERROR_INVALID_PARAMETER (87) but i don't know how to
fix

Roberto @ softimax
Re: Can't find the problem with gdi32 import Softimax
11/3/2005 3:39:28 PM
OK

[quoted text, click to view]

PolyPolyline(hDC, Points, Lenghts, 3);

instead of

PolyPolyline(hDC, Points, Lenghts, 1);

Tanks a lot
AddThis Social Bookmark Button