Mega Code Archive

 
Categories / Delphi / Ide Indy
 

Delphi 6 Imported Automation Events Bug!!!

Title: Delphi 6 - Imported Automation Events Bug!!! Question: Why don't any of the events in my imported ActiveX control work? Answer: Sad but true. Delphi 6's type library importer is badly broken with regards to the event sinks. What's happening is that in InvokeEvent mehod that determines where to send the events by DispID each event handler called has its parameters reversed. So for example in Delphi 5 where it's correct the imported event looks like this; 7: if Assigned(FOnRecognition) then FOnRecognition(Self, Params[0] {Integer}, Params[1] {OleVariant}, Params[2] {SpeechRecognitionType}, Params[3] {const ISpeechRecoResult}); while in Delphi 6 it looks like this; 7: if Assigned(FOnRecognition) then FOnRecognition(Self, Params[3] {const ISpeechRecoResult}, Params[2] {SpeechRecognitionType},Params[1] {OleVariant}, Params[0] {Integer}); which just will not do. The solution is to either 1) fix them all by hand 2) use an import created by Delphi 5 3) try using the unofficial (and unsupported) patch downloadable from http://www.pdmagic.com/download/tlibimp.zip I tried the patch but could not get it to do anything useful. There's no documentation I could find so I guess it's not suprising that I couldn't get it to work. If someone does get it to work please post a how to in the comment below. My choice was to use the import created by Delphi 5. Seemed like the easiest. Apparently Borland is aware of this problem and will provide an official patch some time in the next few months . Hopefully I will be able to figure out how to delete this article once the problems fixed.