如果仅是进程间通信,可以自定义一个消息,明确规定wparam为发送方的PID,lparam为其他的信息。两个要通信的程序达成这种契约,接收方在收到消息后就可以知道wparam就是发送者的PID。但这只适用于自定义的消息。以下代码可以很清楚地说明我的问题。; receiver.au3
#include <WinAPI.au3>
#include <GUITab.au3>
#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Test", 300, 200)
GUICtrlCreateTab(5, 5, 290, 170)
$hTab = GUICtrlGetHandle(-1)
GUICtrlCreateTabItem("Tab 1")
GUICtrlCreateTabItem("Tab 2")
GUICtrlCreateTabItem("Tab 3")
GUICtrlSetState(-1, $GUI_SHOW)
GUICtrlCreateTabItem("")
$hCall = DllCallbackRegister("_TabProc", "int", "hWnd;uint;wparam;lparam")
$pCall = DllCallbackGetPtr($hCall)
$hOldProc = _WinAPI_SetWindowLong($hTab, -4, $pCall)
GUISetState()
Do
Until guiGetMsg() = -3
Func _TabProc($hWnd, $iMsg, $wparam, $lparam)
If $iMsg = $TCM_GETCURSEL Then
If Msgbox(1, '', '截取到消息,发送者的PID?') = 2 Then Return 0
EndIf
Return _WinAPI_CallWindowProc($hOldProc, $hWnd, $iMsg, $wparam, $lparam)
EndFunc ;==>_TabProc()
; sender.au3
#include <GUITab.au3>
$hTab = ControlGetHandle("Test", "", "SysTabControl321")
$iCurSel = _GUICtrlTab_GetCurSel($hTab)
Msgbox(0, '', $iCurSel)
|