lable_read = iup.label{title="聊天信息:"} lable_send = iup.label{title="发送聊天信息:"} btn_read =iup.button{title="接收消息", rastersize="80x22",id="btn_read"} btn_send = iup.button{title="发送消息", rastersize="80x22",id="btn_send"} btn_clearead =iup.button{title="清空接收消息", rastersize="x22"} btn_clearsend = iup.button{title="清空发送消息", rastersize="x22"} btn_open =iup.button{title="开启串口监听", rastersize="x22"} btn_close = iup.button{title="停止串口监听", rastersize="x22"} lable_name = iup.label{title="用户名:"} text_name = iup.text{value="allen",nc="10",size="50x15",mask="(/w)+"} muline_read = iup.multiline{expand="YES"} muline_send = iup.multiline{expand="YES"} dlg = iup.dialog { iup.vbox { iup.hbox { lable_name, text_name, btn_open, btn_close }, lable_read, iup.hbox { muline_read, iup.vbox { btn_read, btn_clearead } ; margin="0x0" }, lable_send, iup.hbox { muline_send, iup.vbox { btn_send, btn_clearsend } ; margin="0x0" } } ;title="串口聊天程序", size="300x200", margin="10x10" } function btn_open:action() result,a=doWorker() if result=="true" then iup.Message("提示","监听开启成功!") else iup.Message("提示","监听已经开启!") end end function btn_close:action() result,a=StopWorker() if result=="true" then iup.Message("提示","停止监听!") else iup.Message("提示","已经停止监听!") end end function btn_send:action() datetime=os.date() result,a=sendComparam(text_name.value.." "..datetime.."\r\n"..muline_send.value,2) end function btn_read:action() result,num=readCtoLua(2) if result~="" then muline_read.value=muline_read.value..result.."\r\n" end end function btn_clearsend:action() muline_send.value="" end function btn_clearead:action() muline_read.value="" end dlg:show()