List of points in VB.net issue

diofantis
diofantis Global Mapper UserTrusted User
edited March 2009 in SDK
Hi Mike,

i have a question about the correct syntax of the GM_LineFeature_t and the GM_AreaFeature_t types, in VB.Net, concerning the mPointList.

Should the mPointList be declared as
1. Public mPointList as IntPtr or
2. Public mPointList() as GM_Point_t.

Of course if someone else (except Mike) is able to create (Poly)lines and Areas in VB.net, is more than welcome to answer.

Thanks in advance.

Comments

  • diofantis
    diofantis Global Mapper User Trusted User
    edited March 2009
    Hi Mike,
    dont bother to reply to me, since i found the answer to my problem.

    The real question was, how to find the address of the first array elent in vb.net and vice versa. This is the reason why i started this discussion and i wanted to start from the definitions.

    At the same time i was trying to find out the solution, so i post it in case someone else has the some question.

    The correct definition of the mPointList is the "Public mPointList as IntPtr".

    In order to find the address of the first array element the following lines should be used:

    Declare Sub RtlMoveMemory Lib "kernel32" (ByVal hpvDest As IntPtr, _
    ByRef hpvSource As gm_point_t, ByVal cbCopy As Integer)
    dim theptr as intptr
    theptr = marshal.allochglobal(n*16) ,where n is the number of points
    Call RtlMoveMemory(theptr, pointlist(0), n *16)

    If someone wants the oposite then:
    Declare Sub RtlMoveMemory Lib "kernel32" (ByRef hpvDest As gm_point_t, _
    ByVal hpvSource As IntPtr, ByVal cbCopy As Integer)
    Dim pointlist() As gm_point_t
    ReDim pointlist(0 to n - 1)
    Call RtlMoveMemory(pointlist(0), theptr, n * 16).

    Thats all.