dgdg Posted July 4, 2006 Share Posted July 4, 2006 (edited) Hi, Yesterday I made my first trials to access the DVBViewer COM interface from VBA (I'm using MS Access, because I'm used to it). I used already some ActiveX controls in other VBA applications but in this cases there was always a VBA template which I could use. Because the DVBViewer COM interface is documented from the view of a Delphi program with Units, I have problems to translate this to VBA. In the object catalog of the VBA editor I see all the classes that are documented in the DVBViewer COM descripton, but I can only access the following classes: DVBViewer DVBViewerEvents MessageEvents Teletextmanager Wenn I try to make an instance of any other class, I get a "methode or data object not found". I generate the instance with a statement like: Set oDVB = New DVBViewerServer.DVBViewer Some lines of sample code would be very helpfull. Sorry for this very basic ActiveX and VBA questions Thx, dgdg Edited July 4, 2006 by dgdg Quote Link to comment
Guest Lars_MQ Posted July 4, 2006 Share Posted July 4, 2006 You only do a getobject for the IDVBViewer Interface. This ist your starting point. Dim myDVBViewer As DVBViewer Set myDVBViewer = GetObject(, "DVBViewerServer.DVBViewer") Everything now is done over the myDVBViewer object. Compare it with the Word or Excel COM-Objects. You get the application opject and everything you need is derived from it. You want the OSD? dim OSD AS IDVBOSD Set OSD = myDVBViewer.OSD OSD.dosomething or call directly myDVBViewer.OSD.doesomething The first approach should be preferred for multiple calls to the OSD, the second one is ok, if you only call one function/property of the OSD, but with several of this kind of call performance degrades extremly. This works with nearly all interfaces. Something special are the Eventhelper. A Short example in WordVBA: MainCode: Dim DVBViewer As IDVBViewer Dim MyEvents As New Klasse1 Private Sub Document_Open() HookItUp End Sub Private Sub HookItUp() Set DVBViewer = GetObject(, "DVBViewerServer.DVBViewer") Set MyEvents.FVideotext = DVBViewer.Videotext Set MyEvents.FDVBEvents = DVBViewer.Events End Sub Klasse1: Public WithEvents FVideotext As DVBViewerServer.Teletextmanager Public WithEvents FDVBEvents As DVBViewerServer.DVBViewerEvents Private Sub FDVBEvents_OnChannelChange(ByVal ChannelNr As Long) If Not FDVBEvents Is Nothing Then Selection.InsertAfter ChannelNr End If End Sub Private Sub FVideotext_onDataArrive(ByVal PageNr As Long, ByVal SubPageNr As Long) If Not FVideotext Is Nothing Then Selection.InsertAfter FVideotext.GetPage(PageNr, SubPageNr) End If End Sub Don't get scared cause the docs look delphi. Everything is explained, the types can be mapped directly into VB types (even this does VB for you, if you use the Objectcatalogue and code completion). Quote Link to comment
dgdg Posted July 4, 2006 Author Share Posted July 4, 2006 (edited) Ok, Thanks a lot ! That was the missing introduction. Till now I used "New" for the ActiveX but with GetObject it's easier. I tested some methodes and it works fine. But one special question. What is wrong with this code ? Dim myDVBViewer As IDVBViewer Dim OSD As IDVBOSD Set myDVBViewer = GetObject(, "DVBViewerServer.DVBViewer") Set OSD = myDVBViewer.OSD OSD.ShowInfoinTVPic("Hello DVBViewer", 3000) I get an error in the last line ("=" is missing) ? The MS Access object catalog and the code completion are telling me, that ShowInfoinTVPic is a procedure (Sub). Something wrong with the parameters ? EDIT: I found the solution right now. I have to use CALL. Thx, dgdg Edited July 4, 2006 by dgdg Quote Link to comment
Guest Lars_MQ Posted July 4, 2006 Share Posted July 4, 2006 OSD.ShowInfoinTVPic("Hello DVBViewer", 3000) That's the way to call a function in VB. to call a sub (or procedure called in the docu) you must use: OSD.ShowInfoinTVPic "Hello DVBViewer", 3000 or put a call in front of it. Quote Link to comment
dgdg Posted July 4, 2006 Author Share Posted July 4, 2006 (edited) I did some C coding in meantime. I have to switch back to the VBA notation now. I think when I fully understand the DVBViewer COM interface I will switch to the Borland C++ Builder. VBA ist only for testing. Thx, dgdg Edited July 4, 2006 by dgdg Quote Link to comment
Guest Lars_MQ Posted July 4, 2006 Share Posted July 4, 2006 Yeah I know, it took me sometime getting again used to some of the specialities of VB Quote Link to comment
steffenvogel Posted July 5, 2006 Share Posted July 5, 2006 Hi, @dgdg: can you post your vba test project? I have some fundamental problems with the COM Interface and VB6 . mfg Steffen Quote Link to comment
dgdg Posted July 15, 2006 Author Share Posted July 15, 2006 (edited) Ok - next step I switched to Borland C++ Builder 4 because from VBS I can not use the Windows API (and I do not want to start MS Access each time to execute mit VBA scripts ) I managed to include the DVBViewer type library in my C++ project and now I see all the types like IDVBOSDDispT etc. in die class tree. But now I have the same problem as in VBA and VBS. I do not know how to access the COM object. What's the C++ Builder equivalent for this VBS code: Set myDVBViewer = GetObject(, "DVBViewerServer.DVBViewer") Set OSD = myDVBViewer.OSD call OSD.ShowInfoinTVPic("Hello DVBViewer", 3000) Who can give ma a short example ? Thx, dgdg Edited July 15, 2006 by dgdg Quote Link to comment
steffenvogel Posted July 15, 2006 Share Posted July 15, 2006 mhm @ dgdg i tried get your code sample working with vb6 and get the following error: "User-defined type not defined" on "Dim myDVBViewer As IDVBViewer" whats wrong? mfg Steffen Quote Link to comment
dgdg Posted July 16, 2006 Author Share Posted July 16, 2006 @ dgdg i tried get your code sample working with vb6 and get the following error: "User-defined type not defined" on "Dim myDVBViewer As IDVBViewer" I kenne VB6 nicht, aber in MS Access muss man die DVBViewer COM Bibliothek vorher unter Extras -> Verweise aktivieren. Dann sind die Typen bekannt. Gruß, dgdg Quote Link to comment
steffenvogel Posted July 16, 2006 Share Posted July 16, 2006 @dgdg: Danke das wars Nur gibt es diese Option unter VB6 unter Projekt -> Verweise. Danach hat noch en bissle gehabert Ich frag mich die ganze Zeit was der zweite Error nur bedeuten soll, bis... vl sollte ich mal den DVBViewer starten Jetzt gehts. juhu!! mfg Steffen Quote Link to comment
dgdg Posted July 16, 2006 Author Share Posted July 16, 2006 Danach hat noch en bissle gehabert Ich frag mich die ganze Zeit was der zweite Error nur bedeuten soll, bis... vl sollte ich mal den DVBViewer starten Jetzt gehts. juhu!! Mit CreateObject statt GetObject wird der DVBViewer automatisch gestartet. Gruß, dgdg Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.