广州高深商电子技术有限公司 用户登录
用户注册 ......
首页 公告 收款机 抽奖机 来电管理 数据采集 台球灯控 软件开发 综合 会员下载 发货查询
公司首页
当前位置:首页>> 来电管理>> 二次开发 >>正文
使用PB开发来电管理软件
chen在2007/8/5发表,被浏览8725
适合对象:记得来电显示管理器
开发环境:PowerBuilder
下载范例:JDDemoPB.rar
下载控件:MSCOMM.rar



注意:需要使用ActiveX控件MSCOMM32.OCX
方法:选择“Insert”-〉“Control”-〉“OLE...”-〉“Insert Object”-〉“Insert Control”-〉“Microsoft Communications Control”


?Generated Application Objectforward
global type jddemo1 from application
string appname = "jddemo1"
string displayname = "来电显示"
end type
global jddemo1 jddemo1

on jddemo1.create
appname="jddemo1"
message=create message
sqlca=create transaction
sqlda=create dynamicdescriptionarea
sqlsa=create dynamicstagingarea
error=create error
end on

on jddemo1.destroy
destroy(sqlca)
destroy(sqlda)
destroy(sqlsa)
destroy(error)
destroy(message)
end on

event open;Open(Form1)
end event


?forward
global type form1 from window
end type
type lb_1 from listbox within form1
end type
type ole_1 from olecustomcontrol within form1
end type
type cb_2 from commandbutton within form1
end type
type cb_1 from commandbutton within form1
end type
type ddlb_1 from dropdownlistbox within form1
end type
type st_1 from statictext within form1
end type
end forward

global type form1 from window
integer width = 1765
integer height = 960
boolean titlebar = true
string title = "来电显示"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
lb_1 lb_1
ole_1 ole_1
cb_2 cb_2
cb_1 cb_1
ddlb_1 ddlb_1
st_1 st_1
end type
global form1 form1

on form1.create
this.lb_1=create lb_1
this.ole_1=create ole_1
this.cb_2=create cb_2
this.cb_1=create cb_1
this.ddlb_1=create ddlb_1
this.st_1=create st_1
this.Control[]={this.lb_1,&
this.ole_1,&
this.cb_2,&
this.cb_1,&
this.ddlb_1,&
this.st_1}
end on


on form1.destroy
destroy(this.lb_1)
destroy(this.ole_1)
destroy(this.cb_2)
destroy(this.cb_1)
destroy(this.ddlb_1)
destroy(this.st_1)
end on

event open;lb_1.Reset()
end event
type lb_1 from listbox within form1
integer x = 59
integer y = 56
integer width = 1074
integer height = 728
integer taborder = 20
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean sorted = false
borderstyle borderstyle = stylelowered!
end type

type ole_1 from olecustomcontrol within form1
event oncomm ( )
integer x = 1303
integer y = 656
integer width = 174
integer height = 152
integer taborder = 40
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
string binarykey = "form1.win"
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
string facename = "Arial"
long textcolor = 33554432
end type

type cb_2 from commandbutton within form1
integer x = 1230
integer y = 508
integer width = 402
integer height = 112
integer taborder = 30
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "关闭"
end type

event clicked;//关闭端口。
ole_1.object.PortOpen = FALSE
lb_1.AddItem("已关闭连接")
end event

type cb_1 from commandbutton within form1
integer x = 1230
integer y = 344
integer width = 402
integer height = 112
integer taborder = 20
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "连接"
end type

event clicked;
String s
Integer k
Integer l
Integer i
Integer p
String ss

//使用COM1端口。
ole_1.object.CommPort = Integer(Right(ddlb_1.Text,1))
//设置速率为9600,无奇偶校验,8 位数据,一个停止位。
ole_1.object.Settings = "9600,N,8,1"
//读入整个缓冲区的数据。
ole_1.object.InputLen = 1
//打开端口
ole_1.object.PortOpen = True
lb_1.Reset()
lb_1.AddItem("已连接,正在监听...")
//等待数据。
Do while True
Do
Yield()
//从Com端口取数据
if not ole_1.object.portopen then Return
s += ole_1.object.Input
LOOP Until(Pos(s, char(85) + char(85) + char(85) + char(85) + char(85) + char(85)) > 0) //Hex=55
Do
Yield()
      s = ole_1.object.Input
Loop Until s <> ""
K = Asc(s)
   Do
Yield()
      s = ole_1.object.Input
   Loop Until s <> ""
   l = Asc(s)
        
   i = 0
   ss = ""
   Do
Yield()
      s = ole_1.object.Input
      If s <> "" Then
       ss = ss + s
         i = i + 1
      End If
   Loop Until i >= l
   //复合数据格式
   If k = 128 Then //Hex=80
     p = Pos(ss, Char(1))
      if p > 0 Then
       l = Asc(Mid(ss, p + 1, 1))
         lb_1.AddItem("来电时间: " + Mid(ss, p + 2, l))
      End If
      p = Pos(ss, Char(2))
      If p > 0 Then
         l = Asc(Mid(ss, p + 1, 1))
         lb_1.AddItem("来电号码: " + Mid(ss, p + 2, l))
      End If
End If
   // 单数据格式
   If k = 4 Then
     lb_1.AddItem("来电时间: " + Mid(ss, 1, 8))
      lb_1.AddItem("来电号码: " + Mid(ss, 9, l - 8))
   End If
   ss = ""
Loop

end event

type ddlb_1 from dropdownlistbox within form1
integer x = 1216
integer y = 160
integer height = 400
integer taborder = 10
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
string text = "COM1"
boolean allowedit = true
string item[] = {"COM1","COM2","COM3","COM4"}
borderstyle borderstyle = stylelowered!
end type

type st_1 from statictext within form1
integer x = 1225
integer y = 56
integer width = 402
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = "连接端口"
boolean focusrectangle = false
end type
【相关文章】
使用PB开发来电管理软件
【同类文章】
高深商GSM无线固话盒OC…
WIFI接口来电显示管理器…
新一代USB转COM口来电…
来电管理器故障排除的方法
在WIN7或Win8中注册…
计算机收发短信的OCX控件…
使用Java开发来电显示管…
开发来电显示及录音程序的C…
C#来电显示管理器开发示例…
使用C#的Socket开发…

广州高深商电子技术有限公司

地址:天河北路908号、高科大厦B座2704
电话:020-38259081、38258857
电子邮箱:gaoykosen@foxmail.com