Mark Gorst Guest
|
Posted: Wed Jun 15, 2005 6:27 pm Post subject: 3rd Party Active X control - odd behaviour |
|
|
I'm using a 3rd party controller for a hi-res digital camera. The manufacturer supplies a series of COM objects which import fine, and give me 11 new entries on my ActiveX control menu. However the behaviour is not as expected. They have a support forum but are not currently replying, and there is already an entry there with exactly the same problem. The supply an example in MS Visual Studio (yawn) which works fine. So it's something with Delphi that's not quite working.
The theory is that there is a camera class which has a list of devices (camera.devices.count) and you pick one and set camera.device to that camera (as you may have more than one connected, plus there is always at least one in a software emulation).
However if you look at camera.devices then it's "nil". So you can't get the device. They have posted a work round whereby you load the another set of controls in the "singleton server" and access the device count list from there, this works fine, but you can't get the
device from that list to assign. In both modules the class of the device is TU1Device, but as the class definitions are from different modules they neither can assign or be cast.
I know that this is really something that the 3rd party should help with, but so far we've not managed to get any help, but are gradually shouting louder and louder.
We're still in Delphi7, as was the other person with the same problem. They tried the fix in Delphi 2005, but didn't take it far enough to be useful.
I was wondering if this rings and bells and anyone has any suggestions as to what I could try next. The relevant bit of posting from their site as an explantion is below, the assignment they can't do is the one I want to do FUICamera.Device and FU1Devices are both of the same type in terms of name (TU1Device) but defined in different modules).
As a work-around, I imported the type library for DsU1.exe (appears as Nikon DS-5M-U1 SDK Server). This out-of-process COM server is the low-level module that creates the U1Devices collection for DsCamera.dll. This collection is a singleton object, so all references point to the same object in memory. So, the following code returns the correct value for the device count:
FU1Devices := TU1Devices.Create (Self);
DeviceCount := FU1Devices.Count;
if DeviceCount > 0 then
begin
FU1Camera := TU1Camera.Create(Self);
// FU1Camera.Device := FU1Devices[0];
AStr := IntToStr(DeviceCount) + ' Devices found.';
end;
Delphi 2005 wouldn't let me do the assignment that is commented out. The reason is that U1Device was qualified differently for each type library. From your note on TImage, you might not have to worry about this with Delphi 7.
We've used Delphi quite successfully with other manufacturers COM objects, but this one has us stumped, especially when it appears to be ok for VC++. Thanks in anticipation
Mark |
|