[WM][VB][DIY想要撥號界面]
以前大家要寫手機播號界面的應用程式都是先把數字畫面拉好在來執行發話動作,在方法有二種第一種是使用 Windows Mobile 6 SDK Microsoft.WindowsMobile.Telephony裡面方法Phone.Talk(電話號碼),第二種是用Windows目錄下的執行檔 cprog. exe “電話號碼”相信大家都很熟這類的寫法,無論上面這二種寫都還是會在叫起下圖的播號界面,透過這個還不錯看的播號界面啦,可是呢我們想要自己做一個是專人所屬的播號界面怎麼辦,今天 “剎很大” 要教大家如何來實作一下
Step1:大家可以先找到喜愛的播號數字圖片,我們可以到微軟的多媒體下載中心去搜尋下載圖片
Step2:開啟vs2008新增一個vb 智慧型裝置專案,把剛才下載回來的圖片10個數字用PictureBox載人,在拉一個 Lable元件背景為黑色用來顯示按下數字號碼,在拉二個按鍵鈕通話、取消
Step3:使用 Enterprise Mobility Developer Kit for .NET加入二 個Tapi及common類別,裡面有寫好的透過P/Invoke API Calls 函式來取用coredll.dll及cellcore來使用。
Step4:撰寫畫面Form1.vb程式碼
Public Class Form1
Dim Phone As New Tapi
Private Sub PictureBox4_Click() Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox9.Click, PictureBox8.Click, PictureBox7.Click, PictureBox6.Click, PictureBox5.Click, PictureBox4.Click, PictureBox3.Click, PictureBox2.Click, PictureBox10.Click, PictureBox1.Click
'把所有圖片按下事件回傳我們預先藏在屬性裡面的Tag數字
'顯示在Label裡面
Me.Label1.Text &= CType(sender, PictureBox).Tag
End Sub
Private Sub Button2_Click() Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'取消播打電話
Me.Label1.Text = ""
Phone.TAPI_DropCall()
End Sub
Private Sub Button1_Click() Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'啟動通話
Phone.TAPI_MakeCall(Label1.Text)
End Sub
'做一個圖片會動訊息代表圖片有被按的感覺
Private Sub PictureBox4_MouseDown() Sub PictureBox4_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox9.MouseDown, PictureBox8.MouseDown, PictureBox7.MouseDown, PictureBox6.MouseDown, PictureBox5.MouseDown, PictureBox4.MouseDown, PictureBox3.MouseDown, PictureBox2.MouseDown, PictureBox10.MouseDown, PictureBox1.MouseDown
'當按下的時候我們要做縮的動作首先圖片縮小移動位置
Dim w As Integer = CType(sender, PictureBox).Width - 10
Dim h As Integer = CType(sender, PictureBox).Height - 10
CType(sender, PictureBox).Size = New Size(w, h)
Dim x As Integer = CType(sender, PictureBox).Left + 10
Dim y As Integer = CType(sender, PictureBox).Top + 10
CType(sender, PictureBox).Location = New System.Drawing.Point(x, y)
End Sub
Private Sub PictureBox4_MouseUp() Sub PictureBox4_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox9.MouseUp, PictureBox8.MouseUp, PictureBox7.MouseUp, PictureBox6.MouseUp, PictureBox5.MouseUp, PictureBox4.MouseUp, PictureBox3.MouseUp, PictureBox2.MouseUp, PictureBox10.MouseUp, PictureBox1.MouseUp
'當放開的時候把剛才的圖片及位置還原
Dim w As Integer = CType(sender, PictureBox).Width + 10
Dim h As Integer = CType(sender, PictureBox).Height + 10
CType(sender, PictureBox).Size = New Size(w, h)
Dim x As Integer = CType(sender, PictureBox).Left - 10
Dim y As Integer = CType(sender, PictureBox).Top - 10
CType(sender, PictureBox).Location = New System.Drawing.Point(x, y)
End Sub
Private Sub Form1_Load() Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在表單啟動的時候開啟TAPI元件
Phone.TAPI_Open()
End Sub
End Class
Dim Phone As New Tapi
Private Sub PictureBox4_Click() Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox9.Click, PictureBox8.Click, PictureBox7.Click, PictureBox6.Click, PictureBox5.Click, PictureBox4.Click, PictureBox3.Click, PictureBox2.Click, PictureBox10.Click, PictureBox1.Click
'把所有圖片按下事件回傳我們預先藏在屬性裡面的Tag數字
'顯示在Label裡面
Me.Label1.Text &= CType(sender, PictureBox).Tag
End Sub
Private Sub Button2_Click() Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'取消播打電話
Me.Label1.Text = ""
Phone.TAPI_DropCall()
End Sub
Private Sub Button1_Click() Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'啟動通話
Phone.TAPI_MakeCall(Label1.Text)
End Sub
'做一個圖片會動訊息代表圖片有被按的感覺
Private Sub PictureBox4_MouseDown() Sub PictureBox4_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox9.MouseDown, PictureBox8.MouseDown, PictureBox7.MouseDown, PictureBox6.MouseDown, PictureBox5.MouseDown, PictureBox4.MouseDown, PictureBox3.MouseDown, PictureBox2.MouseDown, PictureBox10.MouseDown, PictureBox1.MouseDown
'當按下的時候我們要做縮的動作首先圖片縮小移動位置
Dim w As Integer = CType(sender, PictureBox).Width - 10
Dim h As Integer = CType(sender, PictureBox).Height - 10
CType(sender, PictureBox).Size = New Size(w, h)
Dim x As Integer = CType(sender, PictureBox).Left + 10
Dim y As Integer = CType(sender, PictureBox).Top + 10
CType(sender, PictureBox).Location = New System.Drawing.Point(x, y)
End Sub
Private Sub PictureBox4_MouseUp() Sub PictureBox4_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox9.MouseUp, PictureBox8.MouseUp, PictureBox7.MouseUp, PictureBox6.MouseUp, PictureBox5.MouseUp, PictureBox4.MouseUp, PictureBox3.MouseUp, PictureBox2.MouseUp, PictureBox10.MouseUp, PictureBox1.MouseUp
'當放開的時候把剛才的圖片及位置還原
Dim w As Integer = CType(sender, PictureBox).Width + 10
Dim h As Integer = CType(sender, PictureBox).Height + 10
CType(sender, PictureBox).Size = New Size(w, h)
Dim x As Integer = CType(sender, PictureBox).Left - 10
Dim y As Integer = CType(sender, PictureBox).Top - 10
CType(sender, PictureBox).Location = New System.Drawing.Point(x, y)
End Sub
Private Sub Form1_Load() Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在表單啟動的時候開啟TAPI元件
Phone.TAPI_Open()
End Sub
End Class
Step5:我們可以利用cellular Emulator來測試一下,在界面上按下電話號碼後在按通話。