Hi,
I'm pretty new in development. I wrote a litte application that listens to the TAPI events (Phone events) and each time the phone ring i wanted to check who's the caller and pop it in a alert.
The application retrieves the right number but when i show the desktop alert, it seems like freezed and the whole program crashes.
I have noticed, if i call "desktopalert.show()" from within the same form, it works great, but if i try to call it from a class i get the above explicated issues.
Now I wrote a class TAPIExtended with the follwing code and I try to set up and call the show from inside my class:
Dim WithEvents daCall As New Infragistics.Win.Misc.UltraDesktopAlert()
Private Funcion DisplayCallState()
GetCallerInfo(gobjCallInfo.CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER))
End Function
Private Sub GetCallerInfo(ByVal phonenumber As String) Dim ds As New DataSet Dim params(0) As Object params(0) = phonenumber If Me Is Nothing Then Throw New ObjectNotSetException("calldetection") End If ds = Searcher(params, "GetPhoneNumberOwner") MsgBox(ds.Tables(0).Rows(0).Item("Partner")) Me.daCall = New Infragistics.Win.Misc.UltraDesktopAlert() daCall.Style = DesktopAlertStyle.Office2007 daCall.MultipleWindowDisplayStyle = MultipleWindowDisplayStyle.Overlapped daCall.ButtonImageSize = New Size(60, 60) daCall.Appearance.FontData.SizeInPoints = 14 Dim ignoreButton As UltraDesktopAlertButton = New UltraDesktopAlertButton() Dim acceptButton As UltraDesktopAlertButton = New UltraDesktopAlertButton() ignoreButton.Key = "Abweisen" ignoreButton.Appearance.Image = My.Resources.ignore acceptButton.Key = "Annehmen" acceptButton.Appearance.Image = My.Resources.accept daCall.AlertButtons.AddRange(New UltraDesktopAlertButton() {ignoreButton, acceptButton}) AddHandler daCall.AlertButtonClicked, AddressOf daCall_AlertButtonClicked daCall.Show("Anruf du Sau", "Herr " & ds.Tables(0).Rows(0).Item("Partner") & " ruft grad an. Würdest du bitte abnehmen?")
End Sub
Private Sub daCall_AlertButtonClicked(ByVal sender As System.Object, ByVal e As AlertButtonClickedEventArgs) Handles daCall.AlertButtonClicked Select Case e.Button.Key Case "Abweisen" myTapi.HangUp() Case "Annehmen" myTapi.AnswerCall() End SelectEnd Sub
What am I doing wrong? Could you please help me?
Thanks in advance and sorry for my bad english.
Here's one thing you can try, as I don't see this being done in your code:
When you instantiate your Desktop Alert instance, add it to your form. Since this is in a class, you will have to somehow pass your form's reference to the internals of your class. You can pass your form in through your class' constructor, OR if this action is being invoked by your form through calling a method of your class, you can give your method an argument of type Form, and pass in the reference of the form that is calling the method. Either way you choose, the most important thing for you to try is to add the Desktop Alert instance to the Form before you show it.