Bonjour,
J'ai un souci sur l'import dans Delphi d'un composant COM .NET. La bibliothèque est fournie par Philips pour piloter les dictaphones numériques Speechmike, sous forme de fichiers TLB.
J'ai importé via l'EDI Delphi (Version XE5) la bibliothèque de type et généré le composant TSpeechExecDictation qui s'installe dans la palette d'outils. (J'ai essayé aussi avec Delphi 2007 qui génère le meme fichier _TLB.pas avec les memes problèmes).
Toutes les méthodes et propriétés du composant marchent parfaitement bien. Je peux ouvrir / créer un fichier audio, régler de nombreux paramètres, etc...
Ce qui ne fonctionne pas c'est la gestion des Événements. Aucun évènement ne se produit.
Lorsque je crée pour essayer un projet en VB.NET avec une procédure WithEvents les événements sont correctement traités ce qui exclut a priori un probleme du Framework Philips. En particulier l'évènement OnDeviceControlEvent se déclenche normalement quand un bouton du dictaphone est utilisé ce qui est bien pratique pour réagir dans l'application.
Dans un premier temps, j'ai parcouru le fichier PSP_SpeechExec_Dictation_TLB.pas généré, je trouve une première anomalie.
La procédure censée gérer les évènements est mal importée.
En corrigeant cela (Thanks to Remy Lebeau), je n'arrive toujours pas à récupérer les événements.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 procedure TSpeechExecDictation.InvokeEvent(DispID: TDispID; var Params: TVariantArray); begin case DispID of -1: Exit; // DISPID_UNKNOWN (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnUIControlEvent) then FOnUIControlEvent(Self, Params[0] {enUIControlEvent}); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnDeviceControlEvent) then FOnDeviceControlEvent(Self, Params[0] {enAudioControlDeviceEvent}, Params[1] {enAudioControlDevice}); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnErrorEvent) then FOnErrorEvent(Self, Params[0] {enError}); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnHideEvent) then FOnHideEvent(Self); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnCloseEvent) then FOnCloseEvent(Self); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnFileLengthEvent) then FOnFileLengthEvent(Self, Params[0] {Integer}); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnFilePositionEvent) then FOnFilePositionEvent(Self, Params[0] {Integer}); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnStateEvent) then FOnStateEvent(Self, Params[0] {enAudioState}); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnLevelEvent) then FOnLevelEvent(Self, Params[0] {Integer}); *) (*{The DispID for this method is DISPID_UNKNOWN!?. } -1: if Assigned(FOnStereoLevelEvent) then FOnStereoLevelEvent(Self, Params[0] {Integer}, Params[1] {Integer}); *) end; {case DispID} end;
Je mets en PJ le PAS généré et les fichiers TLB.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 procedure TSpeechExecDictation.InvokeEvent(DispID: TDispID; var Params: TVariantArray); begin case DispID of -1: Exit; // DISPID_UNKNOWN 1610743808: if Assigned(FOnUIControlEvent) then FOnUIControlEvent(Self, Params[0] {enUIControlEvent}); 1610743809: if Assigned(FOnDeviceControlEvent) then FOnDeviceControlEvent(Self, Params[0] {enAudioControlDeviceEvent}, Params[1] {enAudioControlDevice}); 1610743810: if Assigned(FOnErrorEvent) then FOnErrorEvent(Self, Params[0] {enError}); 1610743811: if Assigned(FOnHideEvent) then FOnHideEvent(Self); 1610743812: if Assigned(FOnCloseEvent) then FOnCloseEvent(Self); 1610743813: if Assigned(FOnFileLengthEvent) then FOnFileLengthEvent(Self, Params[0] {Integer}); 1610743814: if Assigned(FOnFilePositionEvent) then FOnFilePositionEvent(Self, Params[0] {Integer}); 1610743815: if Assigned(FOnStateEvent) then FOnStateEvent(Self, Params[0] {enAudioState}); 1610743816: if Assigned(FOnLevelEvent) then FOnLevelEvent(Self, Params[0] {Integer}); 1610743817: if Assigned(FOnStereoLevelEvent) then FOnStereoLevelEvent(Self, Params[0] {Integer}, Params[1] {Integer}); end; {case DispID} end;
Si quelqu'un a une idée ?
J'ai essayé également avec EventSinkImp de Laurent Dardenne sans plus de succès.
Merci pour votre aide.
Thomas
Partager