本帖最后由 xzxnovice 于 2011-4-16 22:20 编辑 #include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <winapi.au3>
Global $form1 = GUICreate('Form1', 400, 300)
$hCallback = DllCallbackRegister("My_WindowProc", "int", "hWnd;uint;wparam;lparam")
$tCallback = DllCallbackGetPtr($hCallback)
$CallProc = _WinAPI_SetWindowLong($form1, -4, $tCallback)
$btn=GUICtrlCreateButton("按钮 ",10,10)
$hCallbackbtn = DllCallbackRegister("My_btnProc", "int", "hWnd;uint;wparam;lparam")
$tCallbackbtn = DllCallbackGetPtr($hCallbackbtn)
$CallProcbtn = _WinAPI_SetWindowLong(GUICtrlGetHandle($btn), -4, $tCallbackbtn)
GUISetState()
While GUIGetMsg() <> -3
WEnd
GUIDelete()
;==>__wm_mouseleave
Func My_WindowProc($hwnd, $iMsg, $iwParam, $ilParam)
Switch $iMsg
Case 0x200;WM_MOUSEMOVE
ConsoleWrite("mouse move "&$hwnd&@cr)
EndSwitch
Return _WinAPI_CallWindowProc($CallProc, $hwnd, $iMsg, $iwParam, $ilParam)
EndFunc ;==>My_WindowProc
Func My_btnProc($hwnd, $iMsg, $iwParam, $ilParam)
Switch $iMsg
Case 0x200;WM_MOUSEMOVE
ConsoleWrite("mouse move 0x" & Hex($iMsg,6) &@LF)
EndSwitch
Return _WinAPI_CallWindowProc($CallProcbtn, $hwnd, $iMsg, $iwParam, $ilParam)
EndFunc
点几下按钮,程序会死掉??怎样同时替换窗口和控件过程呢? |