form1.vb

来自「清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码」· VB 代码 · 共 39 行

VB
39
字号
Imports Microsoft.WindowsMobile.PocketOutlook
Imports Microsoft.WindowsMobile.PocketOutlook.MessageInterception
Imports Microsoft.WindowsMobile.Telephony

Public Class Form1
    Private mi As MessageInterceptor

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'setup the sms interceptor
        If MessageInterceptor.IsApplicationLauncherEnabled("Chapter9") Then
            'load existing settings
            Me.mi = New MessageInterceptor("Chapter9")
        Else
            'setup rule and register with application id "Chapter9"
            Me.mi = New MessageInterceptor(InterceptionAction.NotifyAndDelete)
            Me.mi.MessageCondition = New MessageCondition(MessageProperty.Body, MessagePropertyComparisonType.StartsWith, "Chapter9")
            Dim appPath As String = System.Reflection.Assembly.GetExecutingAssembly.GetName.CodeBase
            Me.mi.EnableApplicationLauncher("Chapter9", appPath)
        End If
        AddHandler Me.mi.MessageReceived, New MessageInterceptorEventHandler(AddressOf Me.mi_MessageReceived)

    End Sub

    Private Sub mi_MessageReceived(ByVal sender As Object, ByVal e As MessageInterceptorEventArgs)

        MessageBox.Show(DirectCast(e.Message, SmsMessage).Body, "SMS Received")

    End Sub
    
    Private Sub mnuCall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCall.Click

        Dim p As New Phone()
        p.Talk(Me.txtNumber.Text, True)

    End Sub

End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?