I have this really annoying problem that has had me stumped these last few
days. I have written a control that references the DirectX7a library. This
control raises an userdefined event which includes, as an argument, a
reference to a DX object. The event's declaration looks like this:

Public Event UserPaint(MainSurface As DxVBLib.DirectDrawSurface7)

The problem occurs when you use this control in another application. The
first time you try to run or compile the host application it fails with the
error: "User defined type not defined" with respect to the
'DxVBLib.DirectDrawSurface7' reference in the control's 'UserPaint' event
handler. The handler looks like this

Private Sub DirectView1_UserPaint(MainSurface As DxVBLib.DirectDrawSurface7)
'Draw the groovy graphics
With MainSurface
.SetForeColor RGB(255, 255, 204)
.DrawCircle CircleX, CircleY, 4
.DrawBox BoxX - 7, BoxY - 7, BoxX + 7, BoxY + 7
.DrawLine HLineX - 20, HLineY, HLineX + 20, HLineY
.DrawLine VLineX, VLineY - 20, VLineX, VLineY + 20
End With
End Sub

The 'cure' for this error is simple. You just copy the code in the event
handler, delete the event handler completely, recreate the event handler and
paste the code back in. Then everything is fine until you close and re-open
the project when the error reappears.



Genetic algorithms, fractals, chaos and fun.