Hello again,

in addition to my previous problem I ran into another one when trying to get SlimDx drawing to work.

I have translated the following code from C# to VB

Code:
Imports SlimDX.Direct3D9
Imports SlimDX

Public Class Form1
    Dim devic As Device
    Dim pparams As PresentParameters
    Dim d3dObj As Direct3D
    Dim font_ As SlimDX.Direct3D9.Font
    Dim line As Line

    Private Sub Init(ByVal hWnd As IntPtr, ByVal width As Integer, ByVal height As Integer)


        d3dObj = New Direct3D()
        pparams = New PresentParameters()
        pparams.SwapEffect = SwapEffect.Discard
        pparams.Windowed = True
        pparams.EnableAutoDepthStencil = False
        pparams.BackBufferHeight = height
        pparams.BackBufferWidth = width
        pparams.DeviceWindowHandle = Me.Handle
        pparams.BackBufferCount = 2
        pparams.BackBufferFormat = Format.A8R8G8B8

        devic = New Device(d3dObj, 0, DeviceType.Hardware, Me.Handle, CreateFlags.HardwareVertexProcessing, pparams)
        line = New Line(devic)
        font_ = New SlimDX.Direct3D9.Font(devic, New System.Drawing.Font("Calibri", 14))
    End Sub

    Private Sub DrawBox(ByVal x As Integer, ByVal y As Integer, ByVal w As Integer, ByVal h As Integer, ByVal color As Color)

        Dim vertices As Vector2() =
         {
             New Vector2(x, y),
             New Vector2(x + w, y),
             New Vector2(x + w, y + h),
             New Vector2(x, y + h),
             New Vector2(x, y)
         }
        line.Draw(vertices, color)
        
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        DrawBox(5, 5, 20, 40, Color.Azure)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Init(Me.Handle.ToInt32, Me.Width, Me.Height)
    End Sub
End Class

Unfortunately the 'line.Draw(vertices, color)' throws an exception.

Code:
D3DERR_INVALIDCALL: Invalid call (-2005530516)
Any idea how to fix this? I am hoping to get the app to draw simple shapes which I then hope to transfer onto an external app and make an overlay.