www.pudn.com > SMSDemoALL.zip > FormMain.frm
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{E7A8450E-8A86-4AA2-84B5-1A1CB676C97E}#2.1#0"; "MobileSMS.ocx"
Begin VB.Form FormMain
BorderStyle = 3 'Fixed Dialog
Caption = "MobileSMSDemo"
ClientHeight = 8790
ClientLeft = 1680
ClientTop = 1515
ClientWidth = 11505
LinkTopic = "FormMain"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 8790
ScaleWidth = 11505
ShowInTaskbar = 0 'False
Begin MOBILESMSLib.MobileSMS MobileSMS
Height = 480
Left = 1440
TabIndex = 72
Top = 0
Width = 480
_Version = 131073
_ExtentX = 847
_ExtentY = 847
_StockProps = 0
End
Begin VB.Frame PhoneBook
Caption = "Phone Book"
Height = 6255
Left = 7860
TabIndex = 62
Top = 120
Width = 3495
Begin VB.TextBox PBResult
Height = 4335
Left = 180
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 29
Top = 300
Width = 3135
End
Begin VB.CommandButton PBDelete
Caption = "Delete(SIM)"
Height = 315
Left = 2280
TabIndex = 71
Top = 4800
Width = 1035
End
Begin VB.TextBox PBIndex
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 315
Left = 660
TabIndex = 70
Text = "1"
Top = 4800
Width = 1455
End
Begin VB.CommandButton PBSave
Caption = "Save(SIM)"
Height = 315
Left = 2280
TabIndex = 68
Top = 5280
Width = 1035
End
Begin VB.TextBox PBPhone
Height = 315
Left = 660
TabIndex = 67
Top = 5280
Width = 1455
End
Begin VB.CommandButton PBRefresh
Caption = "Refresh"
Height = 315
Left = 2280
TabIndex = 65
Top = 5760
Width = 1035
End
Begin VB.TextBox PBName
Height = 315
Left = 660
TabIndex = 64
Top = 5760
Width = 1455
End
Begin VB.Label Label24
Caption = "Index"
Height = 255
Left = 120
TabIndex = 69
Top = 4860
Width = 495
End
Begin VB.Label Label23
Caption = "Phone"
Height = 255
Left = 120
TabIndex = 66
Top = 5340
Width = 555
End
Begin VB.Label Label22
Caption = "Name"
Height = 255
Left = 120
TabIndex = 63
Top = 5820
Width = 555
End
End
Begin MSComDlg.CommonDialog FileDlg
Left = 540
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox SMSResult
Height = 2175
Left = 120
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 61
Top = 6480
Width = 11235
End
Begin VB.Frame SMS
Caption = "SMS"
Height = 6255
Left = 3300
TabIndex = 30
Top = 120
Width = 4455
Begin VB.CommandButton SMSReset
Caption = "Reset"
Height = 315
Left = 3420
TabIndex = 60
Top = 5760
Width = 795
End
Begin VB.CommandButton SMSSave
Caption = "Save"
Height = 315
Left = 2340
TabIndex = 59
Top = 5760
Width = 795
End
Begin VB.CommandButton SMSSend
Caption = "Send"
Height = 315
Left = 1260
TabIndex = 58
Top = 5760
Width = 795
End
Begin VB.CommandButton SMSRefresh
Caption = "Refresh"
Height = 315
Left = 180
TabIndex = 57
Top = 5760
Width = 795
End
Begin VB.CheckBox NeedSendReport
Alignment = 1 'Right Justify
Caption = "Need Sent Report"
Height = 315
Left = 2580
TabIndex = 56
Top = 5160
Width = 1695
End
Begin VB.CommandButton SMSDelete
Caption = "Delete"
Height = 315
Left = 1800
TabIndex = 55
Top = 5160
Width = 675
End
Begin VB.TextBox SMSIndex
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 315
Left = 960
TabIndex = 54
Text = "1"
Top = 5160
Width = 735
End
Begin VB.ComboBox OptType
Height = 315
ItemData = "FormMain.frx":0000
Left = 960
List = "FormMain.frx":0040
Style = 2 'Dropdown List
TabIndex = 51
Top = 4680
Width = 3315
End
Begin VB.CommandButton SetSMSC
Caption = "Set"
Height = 315
Left = 3720
TabIndex = 50
Top = 4200
Width = 555
End
Begin VB.CommandButton GetSMSC
Caption = "Get"
Height = 315
Left = 2940
TabIndex = 49
Top = 4200
Width = 555
End
Begin VB.TextBox SMSC
Height = 315
Left = 960
TabIndex = 48
Top = 4200
Width = 1815
End
Begin VB.TextBox MNC
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 315
Left = 2940
TabIndex = 46
Top = 3720
Width = 1335
End
Begin VB.TextBox MCC
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 315
Left = 960
TabIndex = 44
Top = 3720
Width = 1395
End
Begin VB.CommandButton BrowseLogo
Caption = "Browse"
Height = 315
Left = 3480
TabIndex = 42
Top = 3240
Width = 795
End
Begin VB.CommandButton BrowseRingtone
Caption = "Browse"
Height = 315
Left = 3480
TabIndex = 41
Top = 2760
Width = 795
End
Begin VB.TextBox LogoFile
Height = 315
Left = 960
TabIndex = 40
Top = 3240
Width = 2355
End
Begin VB.TextBox Ringtone
Height = 315
Left = 960
TabIndex = 39
Top = 2760
Width = 2355
End
Begin VB.TextBox SMSText
Height = 1695
Left = 180
MultiLine = -1 'True
TabIndex = 36
Top = 900
Width = 4095
End
Begin VB.TextBox Validity
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 315
Left = 3420
TabIndex = 34
Text = "2880"
Top = 300
Width = 855
End
Begin VB.TextBox Phone
Height = 315
Left = 780
TabIndex = 32
Top = 300
Width = 1695
End
Begin VB.Label Label21
Caption = "Index"
Height = 255
Left = 300
TabIndex = 53
Top = 5220
Width = 555
End
Begin VB.Label Label20
Caption = "Type"
Height = 255
Left = 300
TabIndex = 52
Top = 4740
Width = 495
End
Begin VB.Label Label19
Caption = "SMSC"
Height = 255
Left = 240
TabIndex = 47
Top = 4260
Width = 555
End
Begin VB.Label Label18
Caption = "MNC"
Height = 255
Left = 2460
TabIndex = 45
Top = 3780
Width = 555
End
Begin VB.Label Label17
Caption = "MCC"
Height = 195
Left = 300
TabIndex = 43
Top = 3780
Width = 495
End
Begin VB.Label Label16
Caption = "Logo File"
Height = 255
Left = 180
TabIndex = 38
Top = 3300
Width = 735
End
Begin VB.Label Label15
Caption = "Ringtone"
Height = 315
Left = 180
TabIndex = 37
Top = 2820
Width = 855
End
Begin VB.Label Label14
Caption = "Text"
Height = 255
Left = 180
TabIndex = 35
Top = 660
Width = 615
End
Begin VB.Label Label13
Caption = "Validity"
Height = 195
Left = 2700
TabIndex = 33
Top = 360
Width = 555
End
Begin VB.Label Label12
Caption = "Phone"
Height = 195
Left = 180
TabIndex = 31
Top = 360
Width = 795
End
End
Begin VB.Frame Information
Caption = "Information"
Height = 4215
Left = 120
TabIndex = 9
Top = 2160
Width = 3075
Begin VB.TextBox Time
Height = 315
Left = 1140
TabIndex = 27
Top = 3240
Width = 1755
End
Begin VB.CommandButton Call
Caption = "Call"
Height = 315
Left = 2100
TabIndex = 26
Top = 3720
Width = 735
End
Begin VB.CommandButton SetTime
Caption = "SetTime"
Height = 315
Left = 1140
TabIndex = 25
Top = 3720
Width = 735
End
Begin VB.CommandButton InfoRefresh
Caption = "Refresh"
Height = 315
Left = 180
TabIndex = 24
Top = 3720
Width = 735
End
Begin VB.TextBox Version
Height = 315
Left = 1140
TabIndex = 23
Top = 2820
Width = 1755
End
Begin VB.TextBox Signal
Height = 315
Left = 1140
TabIndex = 22
Top = 2400
Width = 1755
End
Begin VB.TextBox Battery
Height = 315
Left = 1140
TabIndex = 21
Top = 1980
Width = 1755
End
Begin VB.TextBox NetInfo
Height = 315
Left = 1140
TabIndex = 20
Top = 1560
Width = 1755
End
Begin VB.TextBox IMEI
Height = 315
Left = 1140
TabIndex = 19
Top = 1140
Width = 1755
End
Begin VB.TextBox Model
Height = 315
Left = 1140
TabIndex = 18
Top = 720
Width = 1755
End
Begin VB.TextBox Manufacture
Height = 315
Left = 1140
TabIndex = 17
Top = 300
Width = 1755
End
Begin VB.Label Label11
Caption = "IMEI"
Height = 195
Left = 360
TabIndex = 28
Top = 1200
Width = 495
End
Begin VB.Label Label10
Caption = "Time"
Height = 255
Left = 360
TabIndex = 16
Top = 3240
Width = 495
End
Begin VB.Label Label9
Caption = "Version"
Height = 255
Left = 300
TabIndex = 15
Top = 2880
Width = 615
End
Begin VB.Label Label8
Caption = "Signal"
Height = 315
Left = 300
TabIndex = 14
Top = 2460
Width = 675
End
Begin VB.Label Label7
Caption = "Battery"
Height = 255
Left = 300
TabIndex = 13
Top = 2040
Width = 615
End
Begin VB.Label Label6
Caption = "Net Info"
Height = 255
Left = 240
TabIndex = 12
Top = 1620
Width = 735
End
Begin VB.Label Label5
Caption = "Model"
Height = 255
Left = 300
TabIndex = 11
Top = 780
Width = 555
End
Begin VB.Label Label4
Caption = "Manufacture"
Height = 195
Left = 120
TabIndex = 10
Top = 360
Width = 915
End
End
Begin VB.Frame Connection
Caption = "Connection"
Height = 1995
Left = 120
TabIndex = 0
Top = 120
Width = 3075
Begin VB.TextBox ComPort
Height = 285
Left = 1200
TabIndex = 8
Text = "1"
Top = 720
Width = 1695
End
Begin VB.CommandButton Disconnect
Caption = "Disconnect"
Height = 315
Left = 1680
TabIndex = 7
Top = 1560
Width = 975
End
Begin VB.CommandButton Connect
Caption = "Connect"
Height = 315
Left = 360
TabIndex = 6
Top = 1560
Width = 975
End
Begin VB.ComboBox ComBaudrate
Height = 315
ItemData = "FormMain.frx":0172
Left = 1200
List = "FormMain.frx":0182
Style = 2 'Dropdown List
TabIndex = 5
Top = 1080
Width = 1695
End
Begin VB.ComboBox ConnectionMode
Height = 315
ItemData = "FormMain.frx":01A2
Left = 1200
List = "FormMain.frx":01AC
Style = 2 'Dropdown List
TabIndex = 4
Top = 300
Width = 1695
End
Begin VB.Label Label3
Caption = "ComBaudrate"
Height = 255
Left = 120
TabIndex = 3
Top = 1140
Width = 975
End
Begin VB.Label Label2
Caption = "ComPort"
Height = 255
Left = 240
TabIndex = 2
Top = 720
Width = 735
End
Begin VB.Label Label1
Caption = "Mode"
Height = 195
Left = 360
TabIndex = 1
Top = 360
Width = 495
End
End
End
Attribute VB_Name = "FormMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub BrowseLogo_Click()
On Error GoTo Err
FileDlg.CancelError = True
FileDlg.ShowOpen
LogoFile = FileDlg.FileName
Err:
End Sub
Private Sub BrowseRingtone_Click()
On Error GoTo Err
FileDlg.CancelError = True
FileDlg.ShowOpen
Ringtone = FileDlg.FileName
Err:
End Sub
Private Sub Call_Click()
FormCall.Show (1)
End Sub
Private Sub Connect_Click()
MobileSMS.Disconnect
MobileSMS.ConnectionMode = ConnectionMode.ListIndex
MobileSMS.ComNumber = ComPort
MobileSMS.ComBaudrate = ComBaudrate.Text
If MobileSMS.Connect < 0 Then
MsgBox ("Failed!")
Else
InfoRefresh_Click
End If
End Sub
Private Sub Disconnect_Click()
MobileSMS.Disconnect
End Sub
Private Sub Form_Load()
MobileSMS.Visible = True
MobileSMS.Top = -1000
ConnectionMode.ListIndex = 1
ComBaudrate.ListIndex = 0
OptType.ListIndex = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
MobileSMS.Disconnect
End Sub
Private Sub GetSMSC_Click()
SMSC = MobileSMS.GetSMSCNumber
End Sub
Private Sub InfoRefresh_Click()
Manufacture = MobileSMS.GetManufacturer
Model = MobileSMS.GetModel
IMEI = MobileSMS.GetIMEI
NetInfo = MobileSMS.GetNetInfo
Battery = MobileSMS.GetBatteryLevel
Signal = MobileSMS.GetSignalLevel
Version = MobileSMS.GetVersion
Time = MobileSMS.GetTime
MCC = MobileSMS.MobileMCC
MNC = MobileSMS.MobileMNC
GetSMSC_Click
End Sub
Private Sub MobileSMS_NewIncommingCall(ByVal Phone As String)
FormCall.Phone = Phone
FormCall.Show (1)
End Sub
Private Sub MobileSMS_NewMsg(ByVal Index As Long, ByVal Phone As String, ByVal Text As String, ByVal Time As String, ByVal Code As Long)
MsgBox ("New message: " & Index & "," & Time & "," & Phone & "," & Text)
SMSRefresh_Click
End Sub
Private Sub MobileSMS_NewReport(ByVal Index As Long, ByVal Phone As String, ByVal Time As String, ByVal Delivery As Long)
MsgBox ("New report: " & Index & "," & Time & "," & Phone & "," & Delivery)
End Sub
Private Sub PBDelete_Click()
If PBIndex <> "" Then
MobileSMS.PBSetStorage ("SM")
If MobileSMS.PBDelete(PBIndex) < 0 Then
MsgBox ("Failed!")
Else
MsgBox ("Successful!")
End If
End If
End Sub
Private Sub PBRefresh_Click()
Dim i, j, lCapability, lCount, lReaded As Long
Dim strTemp As String
PBResult = ""
For j = 1 To 5
Select Case j
Case 1: strTemp = "MC"
PBResult = PBResult & "<<<<<<<<<<>>>>>>>>>" & vbCrLf
Case 2: strTemp = "LD"
PBResult = PBResult & "<<<<<<<<<<>>>>>>>>>" & vbCrLf
Case 3: strTemp = "RC"
PBResult = PBResult & "<<<<<<<<<>>>>>>>>" & vbCrLf
Case 4: strTemp = "SM"
PBResult = PBResult & "<<<<<<<<<<<<<>>>>>>>>>>>>" & vbCrLf
Case 5: strTemp = "ME"
PBResult = PBResult & "<<<<<<<<<<<<>>>>>>>>>>>" & vbCrLf
End Select
If MobileSMS.PBSetStorage(strTemp) > 0 Then
lCapability = MobileSMS.PBGetCapability()
If lCapability > 10 Then
lCapability = 10
End If
lCount = MobileSMS.PBGetCount()
lReaded = 0
For i = 1 To lCapability
PBResult = PBResult & i & " "
If lReaded < lCount Then
If MobileSMS.PBRead(i) > 0 Then
PBResult = PBResult & MobileSMS.PBLastReadPhone & " "
PBResult = PBResult & MobileSMS.PBLastReadName
lReaded = lReaded + 1
End If
End If
PBResult = PBResult & vbCrLf
Next i
End If
Next j
End Sub
Private Sub PBSave_Click()
MobileSMS.PBSetStorage ("SM")
If MobileSMS.PBSave(PBIndex, PBPhone, PBName) < 0 Then
MsgBox ("Failed!")
Else
MsgBox ("Successful!")
End If
End Sub
Private Sub SetSMSC_Click()
If MobileSMS.SetSMSCNumber(SMSC) < 0 Then
MsgBox ("Failed!")
Else
MsgBox ("Successful!")
End If
End Sub
Private Sub SetTime_Click()
If MobileSMS.SetTime(Time) < 0 Then
MsgBox ("Failed!")
Else
MsgBox ("Successful!")
End If
End Sub
Private Sub SMSDelete_Click()
If SMSIndex <> "" Then
If MobileSMS.SMSDelete(SMSIndex) < 0 Then
MsgBox ("Failed!")
Else
MsgBox ("Successful!")
End If
End If
End Sub
Private Sub SMSRefresh_Click()
Dim lCapability, lCount, lReaded As Long
lCapability = MobileSMS.SMSGetCapability
If lCapability > 20 Then
lCapability = 20
End If
lCount = MobileSMS.SMSGetCount
lReaded = 0
SMSResult = ""
For i = 1 To lCapability
SMSResult = SMSResult & i & " "
If lReaded < lCount Then
If MobileSMS.SMSRead(i) > 0 Then
SMSResult = SMSResult & MobileSMS.SMSLastReadTime & " "
SMSResult = SMSResult & MobileSMS.SMSLastReadPhone & " "
SMSResult = SMSResult & MobileSMS.SMSLastReadText & " "
lReaded = lReaded + 1
End If
End If
SMSResult = SMSResult & vbCrLf
Next i
End Sub
Private Sub SMSReset_Click()
Dim lCode, lResult As Long
lCode = 0
lResult = -1
'MobileSMS.SMSSendValidity = Validity
'MobileSMS.SMSSendNeedReport = NeedSendReport
'MobileSMS.MobileMCC = MCC 'Nokia Only
'MobileSMS.MobileMNC = MNC 'Nokia Only
Select Case OptType.ListIndex
Case 12: lCode = 1001 'NOKIA CLI LOGO
Case 13: lCode = 1002 'NOKIA OPERATOR LOGO
Case 14: lCode = 1004 'NOKIA PICTURE
Case 15: lCode = 1011 'SIEMENS LOGO
Case 16: lCode = 1021 'ALCATEL LOGO
Case 17: lCode = 1031 'MOTOROLA LOGO
Case 18: lCode = 1041 'EMS LOGO
Case 19: lCode = 1051 'SAMSUNG LOGO
End Select
If lCode > 1000 And lCode < 2000 Then
lResult = MobileSMS.LogoReset(lCode)
End If
If lResult < 0 Then
MsgBox "Failed!"
Else
MsgBox "Successful!"
End If
End Sub
Private Sub SMSSave_Click()
Dim lCode, lResult As Long
lCode = 0
lResult = -1
MobileSMS.SMSSendValidity = Validity
MobileSMS.SMSSendNeedReport = NeedSendReport
MobileSMS.MobileMCC = MCC 'Nokia Only
MobileSMS.MobileMNC = MNC 'Nokia Only
Select Case OptType.ListIndex
Case 0: lCode = 1 'TEXT MESSAGE
Case 1: lCode = 2 'LONG TEXT MESSAGE
Case 2: lCode = 3 'AUTOSHOW TEXT MESSAGE
Case 3: lCode = 4 'FLASH TEXT MESSAGE
Case 5: lCode = 2001 'NOKIA RINGTONE
Case 6: lCode = 2011 'SIEMENS RINGTONE
Case 7: lCode = 2021 'ALCATEL RINGTONE
Case 8: lCode = 2031 'MOTOROLA RINGTONE
Case 9: lCode = 2041 'EMS RINGTONE
Case 10: lCode = 2051 'SAMSUNG RINGTONE
Case 12: lCode = 1001 'NOKIA CLI LOGO
Case 13: lCode = 1002 'NOKIA OPERATOR LOGO
Case 14: lCode = 1004 'NOKIA PICTURE
Case 15: lCode = 1011 'SIEMENS LOGO
Case 16: lCode = 1021 'ALCATEL LOGO
Case 17: lCode = 1031 'MOTOROLA LOGO
Case 18: lCode = 1041 'EMS LOGO
Case 19: lCode = 1051 'SAMSUNG LOGO
End Select
If lCode > 2000 Then
lResult = MobileSMS.RingtoneSave(Ringtone, lCode, 0)
ElseIf lCode > 1000 Then
lResult = MobileSMS.LogoSave(LogoFile, lCode)
Else
lResult = MobileSMS.SMSSave(Phone, SMSText, lCode)
End If
If lResult < 0 Then
MsgBox "Failed!"
Else
MsgBox "Successful!"
End If
End Sub
Private Sub SMSSend_Click()
Dim lCode, lResult As Long
lCode = 0
lResult = -1
MobileSMS.SMSSendValidity = Validity
MobileSMS.SMSSendNeedReport = NeedSendReport
If MCC <> "" Then
MobileSMS.MobileMCC = MCC 'Nokia Only
End If
If MNC <> "" Then
MobileSMS.MobileMNC = MNC 'Nokia Only
End If
Select Case OptType.ListIndex
Case 0: lCode = 1 'TEXT MESSAGE
Case 1: lCode = 2 'LONG TEXT MESSAGE
Case 2: lCode = 3 'AUTOSHOW TEXT MESSAGE
Case 3: lCode = 4 'FLASH TEXT MESSAGE
Case 5: lCode = 2001 'NOKIA RINGTONE
Case 6: lCode = 2011 'SIEMENS RINGTONE
Case 7: lCode = 2021 'ALCATEL RINGTONE
Case 8: lCode = 2031 'MOTOROLA RINGTONE
Case 9: lCode = 2041 'EMS RINGTONE
Case 10: lCode = 2051 'SAMSUNG RINGTONE
Case 12: lCode = 1001 'NOKIA CLI LOGO
Case 13: lCode = 1002 'NOKIA OPERATOR LOGO
Case 14: lCode = 1004 'NOKIA PICTURE
Case 15: lCode = 1011 'SIEMENS LOGO
Case 16: lCode = 1021 'ALCATEL LOGO
Case 17: lCode = 1031 'MOTOROLA LOGO
Case 18: lCode = 1041 'EMS LOGO
Case 19: lCode = 1051 'SAMSUNG LOGO
End Select
If lCode > 2000 Then
lResult = MobileSMS.RingtoneSend(Phone, Ringtone, lCode)
ElseIf lCode > 1000 Then
lResult = MobileSMS.LogoSend(Phone, LogoFile, lCode)
Else
lResult = MobileSMS.SMSSend(Phone, SMSText, lCode)
End If
If lResult < 0 Then
MsgBox "Failed!"
Else
MsgBox "Successful!"
End If
End Sub