本帖最后由 muxingwan 于 2010-2-5 15:21 编辑
当使用CoProcSend时,无法发送最后一个字符到父窗口.经过多次测试都是这种情况,现在没有时间找问题,我的解决办法是,在发送字符的时候多加一个" "Func auto_Refresh()
; 定时检测状态
Local $logFlag = 1
If $logFlag = 1 Then write_log(@CRLF)
If $logFlag = 1 Then write_log("开始自动刷新模块")
If _WaitNetConnect() = 0 Then Return
Local $strSourceFile = @ScriptDir & "\data.xml"
Local $xh
If Not FileExists($strSourceFile) Then Return
$objXML = ObjCreate("Microsoft.XMLDOM");创建XML对像
$sFile = $objXML.load($strSourceFile)
$objRootsite = $objXML.documentElement.selectSingleNode("NewList")
$AllNodesNum = $objRootsite.childNodes.length - 1
If $logFlag = 1 Then write_log("共有" & $AllNodesNum + 1 & "条数据")
For $id = 0 To $AllNodesNum
If Not ProcessExists($gi_CoProcParent) Then Return
$objXML1 = ObjCreate("Microsoft.XMLDOM");创建XML对像
$sFile1 = $objXML1.load($strSourceFile)
$objRootsite1 = $objXML1.documentElement.selectSingleNode("NewList")
$AllNodesNum1 = $objRootsite1.childNodes.length - 1
If $AllNodesNum <> $AllNodesNum1 Then Return
Local $custName = ""
Local $tidanName = ""
Local $YunDiState = ""
Local $FangXingState = ""
Local $BeiZhu = ""
Local $sendToParentFlag = 1
If $logFlag = 1 Then write_log("当前ID:" & $id)
$custName = $objRootsite.childNodes.item($iD).childNodes.item(0).text
$tidanName = $objRootsite.childNodes.item($iD).childNodes.item(1).text
$YunDiState = $objRootsite.childNodes.item($iD).childNodes.item(2).text
$FangXingState = $objRootsite.childNodes.item($iD).childNodes.item(3).text
$BeiZhu = $objRootsite.childNodes.item($iD).childNodes.item(5).text
If $logFlag = 1 Then write_log("当前ID:" & $id & "准备检测网页内容")
If $YunDiState = "OK" And $FangXingState = "OK" Then
If $logFlag = 1 Then write_log("当前ID:" & $id & "跳过" & $tidanName)
ContinueLoop
ElseIf $YunDiState = "OK" And $FangXingState = "" Then
If _FangXing_FUNC($tidanName, $xh, "0") <> 0 Then
$FangXingState = "OK"
$sendToParentFlag = 0
EndIf
Else
If _YunDi_FUNC($tidanName, $xh, "0") <> 0 Then
$YunDiState = "OK"
$sendToParentFlag = 0
EndIf
If _FangXing_FUNC($tidanName, $xh, "0") <> 0 Then
$FangXingState = "OK"
$sendToParentFlag = 0
EndIf
EndIf
$objRootsite.childNodes.item($iD).childNodes.item(2).text = $YunDiState
$objRootsite.childNodes.item($iD).childNodes.item(3).text = $FangXingState
$objRootsite.childNodes.item($iD).childNodes.item(4).text = @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
$objXML.save($strSourceFile)
If $logFlag = 1 Then write_log("当前ID:" & $id & "检测完毕" & $tidanName)
If ProcessExists($gi_CoProcParent) Then
If $sendToParentFlag = 0 Then
;向父进程发送消息,$gi_CoProcParent是父进程的PID,这个变量是函数自己建立的
_CoProcSend($gi_CoProcParent, $custName & "|" & $tidanName & "|" & $YunDiState & "|" & $FangXingState & " ")
If $logFlag = 1 Then write_log("向父进程发送有更新标识")
Else
_CoProcSend($gi_CoProcParent, "onlyRefresh")
If $logFlag = 1 Then write_log("向父进程发送无更新标识")
EndIf
Else
If $logFlag = 1 Then write_log("父进程不存在")
Return
EndIf
Next
If $logFlag = 1 Then write_log("自动刷新模块完成")
EndFunc ;==>auto_Refresh
Func Reciver($vParameter);$vParameter里就是子进程发来的消息 MsgBox(0,"","test")
ReaDdata_xml()
If $logFlag = 1 Then write_log("子进程要求刷新")
If $logFlag = 1 Then write_log("收到子进程信息:" & $vParameter)
Local $msgText = ""
Local $aParam
If $vParameter <> "onlyRefresh" Then
$aParam = StringSplit($vParameter, "|")
If $aParam[1] <> "" Then $msgText = $msgText & "客 户: " & $aParam[1] & @CRLF
If $aParam[2] <> "" Then $msgText = $msgText & "提单号: " & $aParam[2] & @CRLF
If $aParam[3] <> "" Then $msgText = $msgText & "运 抵: " & $aParam[3] & @CRLF
If $aParam[4] <> "" Then $msgText = $msgText & "放 行: " & $aParam[4] & @CRLF
WinSetState($Title, "", @SW_SHOW)
MsgBox(0, "请注意", $msgText)
EndIf
EndFunc ;==>Reciver
|