Rocket Software Homepage
Forum Home Forum Home > AccuTerm Knowledge Base (read only) > Advanced Features
  New Posts New Posts RSS Feed - Converting VB to ObjBridge
  FAQ FAQ  Forum Search   Register Register  Login Login

The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum.

Forum LockedConverting VB to ObjBridge

 Post Reply Post Reply
Author
Message
mlucas67 View Drop Down
Senior Member
Senior Member


Joined: February 12 2007
Location: United States
Status: Offline
Points: 103
Post Options Post Options   Thanks (0) Thanks(0)   Quote mlucas67 Quote  Post ReplyReply Direct Link To This Post Topic: Converting VB to ObjBridge
    Posted: July 27 2010 at 12:20am
Can this be changed into Object Bridge?
 

Imports STMLCONTROLLib
Public Class frmSTCallLogTest
Private WithEvents STCtl As STMLCONTROLLib.Ctl
Private nLineID As Long
 
Private Sub frmSTCallLogTest_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
   STCtl = New STMLCONTROLLib.Ctl
   ' Once the control is created, we initialize it
   STCtl.Initialize()
End Sub
 
Private Sub STCtl_EventReady() Handles STCtl.EventReady
   Dim CtlEvent() As Object
 
   Do
      CtlEvent = STCtl.GetNextEvent()
      Dim ev As ControlEvent
      ev = CtlEvent(0)
      ' If no more events are pending then get out and wait for
      ' next callback
      If ev = ControlEvent.cevNone Then Exit Do
      ' Is this a line state event?
      If ev = ControlEvent.cevLineState Then
         ' LINESTATE EVENT
         ' Get the line ID for the event
         Dim nLineEventLineID As Long
         nLineEventLineID = CtlEvent(1)
         ' Get the line state for the event
         Dim LineState As ShoreTelLineState
         LineState = CtlEvent(2)
         ' Have we set our line yet?
         If nLineID = 0 And _
            LineState = ShoreTelLineState.slsCreated Then
            ' Nope, we need to check to see if we want to use
            ' this line
            ' If the user passed a command line, we use that
            ' as the line address.
            ' If not then we use the first ShoreTel line we
            ' are notified about'
            ' On a client, this will be user's station address
            ' as clients only have
            ' a single ShoreTel line
            ' If the command line is empty then use this line
            If Command() = "" Then
               nLineID = nLineEventLineID
            Else
               ' They are looking for a specific line, retrieve
               ' new line's address
               Dim strAddress As String
               strAddress = STCtl.LineGetAddress(nLineEventLineID)
               If Command() = strAddress Then
                  nLineID = nLineEventLineID
            End If
            ' Open the line if we set it
            If nLineID <> 0 Then STCtl.LineOpen(nLineID)
            ElseIf nLineID <> 0 And nLineEventLineID = nLineID Then
               ' We already have a line
               ' If this line was removed then clear our line
               If LineState = ShoreTelLineState.slsRemoved Then
                  nLineID = 0
            End If
            ' Update the the button state to reflect the
            ' inservice and connected status of the line
            If nLineID = 0 Then
               labelLineStatus.Text = "NO LINE"
            Else
               If STCtl.LineIsConnectedInService(nLineID) Then
                  labelLineStatus.Text = _
                     STCtl.LineGetAddress(nLineID) + ": OPEN"
               ElseIf STCtl.LineIsInService(nLineID) Then
                  labelLineStatus.Text = _
                     STCtl.LineGetAddress(nLineID) + _
                     ": UNCONNECTED"
               Else
                  labelLineStatus.Text = _
                     STCtl.LineGetAddress(nLineID) + _
                     ": OUT OF SERVICE"
            End If
         End If
         ' Is this a call state event?
     ElseIf ev = ControlEvent.cevCallState Then
         Dim nCallEventLineID As Long
         nCallEventLineID = CtlEvent(1)
         Dim nCallEventCallID As Long
         nCallEventCallID = CtlEvent(2)
         Dim CallEventCallState As TAPICallState
         CallEventCallState = CtlEvent(3)
         ' CtlEvent(4) contains the call state details
         ' CtlEvent(5) contains source line ID if the
         ' call was transfered
         ' CtlEvent(6) contains source call ID if the
         ' call was transfered
         ' Is this an offering call?
         If CallEventCallState = TAPICallState.tcsOffering Then
            ' Yes, we want to add it to our list
            ' First, are there more then 10 entries in the list?
            If Log.Items.Count = 10 Then
               ' Yes, remove the last one
               Log.Items.Remove(Log.Items.Count - 1)
            End If
            ' Now add this item as the first item in the list
            Dim str As String
            str = STCtl.CallGetCallerID(nCallEventCallID)
            If (Microsoft.VisualBasic.Left(str, 2) = "+1") Then
               str = DateTime.Now.ToString + " " + _
                     Microsoft.VisualBasic.Right(str, 10)
            Clipboard.Clear()
            Clipboard.SetDataObject(str, True)
            Log.Items.Add(str)
         End If
      End If
   Loop
End Sub
End Class
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: July 27 2010 at 3:51am
Hi Marshall -

I don't think you can convert the code above to use ObjectBridge. The problem is that ObjectBridge does not allow creating ActiveX Controls. Only simple Automation compatible objects are supported. Controls are much more complex and require their container to support a bunch of COM interfaces. On the other hand, you probably could create a DLL that hosts the control and exposes a simple public class to interact with the control. You could then use ObjectBridge to access your simple class. Maybe the vendor of the control has a simple object available as well?

Thanks,

Pete
Back to Top
mlucas67 View Drop Down
Senior Member
Senior Member


Joined: February 12 2007
Location: United States
Status: Offline
Points: 103
Post Options Post Options   Thanks (0) Thanks(0)   Quote mlucas67 Quote  Post ReplyReply Direct Link To This Post Posted: July 27 2010 at 4:39am
Thanks, Pete, that sort of what I figured but I wasn't sure.  Would be nice if there where a more robust interface between ATGUI and VB.NET, but I know that's not the niche it's filling.  Right now I shove the data into the clipboard and my ATGUI app polls every 2 seconds to see if there's anything in the clipboard then checks for events again.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.