I have a VB.NET application and use some third party (closed source) ActiveX controls. One of the controls represents a "camera" (connected over several interfaces) and I try to write an example how to work with several cameras in one application. To do this I allocate multiple "camera" objects dynamically as an array which works as expected like this:
Const NUM_CAMERAS = 2
Private MyCameras(NUM_CAMERAS ) As xxx.MCamera
But the camera objects needs to be allocated with WithEvents
because they raise events when a new image was taken. I found out that WithEvents variables cannot be typed as arrays and this is a pretty common problem so I also found some workarounds: http://www.dreamincode.net/code/snippet885.htm
http://www.xtremevbtalk.com/archive/index.php/t-223970.html
This is already pretty helpful and I adopted this to my concept. So I have a MyCameras array and a MyCamera all "without Events", first allocate a new MyCamera object, add a event handler and then put it into the array. Unfortunately I get an error when calling
AddHandler Camera.ProcessModifiedImage, AddressOf MyHook
Normally "MyHook" is declared as
Private Sub MyHook (ByVal sender As Object, ByVal ModifiedBuffer As xxx.ProcessModifiedImageEvent) Handles Camera.ProcessModifiedImage
Like in the "Button examples" I just removed the "Handles Camera.ProcessModifiedImage" but I get an error that "MyHook" has not the same signature as the Delegate
Delegate Sub ICameraEvents_ProcessModifiedImageEventHandler(ImageIndex as Integer)
Has anyone an idea how to get around this and what to change? I can post more code and details tomorrow if necessary.