PHP Code:
Global $aNotifyHwnd[1][2]
Global Const $UDF_WM_NOTIFY = 0x004E
Global Const $UDF_tagNMHDR = "hwnd hWndFrom;int IDFrom;int Code;int wparam"
Global $hTimerCallBackHandle
Global $sExtNotify
; #FUNCTION# =====================================================================================================================================================================
; Name...........: _Notify_SetHandletoFunc
; Description ...: Ordnet einem Handle eine Funktion zu
; Syntax.........: _Notify_SetHandletoFunc($hWnd, $Function = "", $aFilter="")
; Parameters ....: $hWnd - Handle oder ControlId des Controls
; $Function - Funktion die dem ControlHandle zugeordnet werden soll. Wenn "" dann wird der Eintrag aus dem Array gelöscht
; $aFilter - Übergabe eines Array´s das die Notify Codes enthällt die an die Funktion weitergeleitet werden. Wenn nicht gesetzt,
; werden alle NotifyCodes an die Funktion weitergeleitet
; Return values .: Success - 1
; Failure - -1, sets @error to:
; |1 - Übergebenes Handle ist kein Handle
; |2 - Handle existiert nicht im Array und kann deshalb nicht zurückgesetzt werden
; |3 - Zu einem Handle wurde eine Funktion zugeordnet, zuordnung einer Funktion zu NotifyCode nicht möglich.
;; Author ........: Raupi @ Autoit.de
; Modified.......:
; Remarks .......: Zugeordnete Funktionen müssen den Parameterkopf $hWndFrom, $iIDFrom, $iNotifyCode, $wParam, $lParam haben
;; Wenn Parameter $iNotifyCode und $Function nicht gesetzt sind, werden die dem Handle($ihWnd) gehörenden Zuordnungen gelöscht.
; Wenn per iNotifyCode = "Func" einem Handle eine Funktion zugeordnet wurde, werden Zuordnungen einer Funktion, zu einem NotifyCode für diese Handle ignoriert.
; Wird per NotifyCode = "Func" einem Handle eine Funktion zugeordnet, dann werden alle Funktionszuordnungen zu den NotifyCodes für dieses Handle gelöscht.
; ================================================================================================================================================================================
Func _Notify_SetHandletoFunc($hWnd, $Function = "", $aFilter="")
Local $iResultHandle
If Not IsHWnd($hWnd) Then
$hWnd = GUICtrlGetHandle($hWnd)
If $hWnd = 0 Then Return SetError(1, 0, -1)
EndIf
If $Function = "" then _Notify_SetNotifytoFunc($hWnd)
If @Error then Return SetError(2,0,-1)
If Not IsArray($aFilter) And $Function <>"" Then
_Notify_SetNotifytoFunc($hWnd, "", $Function )
If @error then Return SetError(3,0,-1)
Return 1
Endif
If IsArray($aFilter) Then
For $i = 1 to Ubound ($aNotifyHwnd, 1) - 1
If $aNotifyHwnd[$i][0] = $hWnd Then $iResultHandle = $i
Next
If $iResultHandle <> 0 then _Notify_SetNotifytoFunc($hWnd, "", "" )
For $i= 0 to Ubound($aFilter)-1
_Notify_SetNotifytoFunc($hWnd, $aFilter[$i], $Function )
Next
Return 1
EndIf
EndFunc
Func _Set_Ext_NotifyFunc($Function)
$sExtNotify = $Function
EndFunc
; #FUNCTION# =====================================================================================================================================================================
; Name...........: _Notify_SetNotifytoFunc
; Description ...: Ordnet einem Handle oder einem NotifyCode eine Funktion zu
; Syntax.........: _Notify_SetNotifytoFunc($hWnd, [$iNotifyCode = ""[, $Function = ""]])
; Parameters ....: $hWnd - Handle oder ControlId des Controls (Wenn Parameter 2 und 3 nicht gesetzt, werden Zuordnungen zum Handle gelöscht)
; $iNotifyCode - NotifyCode für das eine Funktion zugeordnet werden soll. Ist iNotifyCode = "Func" wird die Funktion dem Handle zugeordnet
; $Function - Funktion die dem NotifyCode oder dem ControlHandle zugeordnet werden soll. Wenn "" dann wird der Eintrag aus dem Array gelöscht
;
; Return values .: Success - 1
; Failure - -1, sets @error to:
; |1 - Übergebenes Handle ist kein Handle
; |2 - Handle existiert nicht im Array und kann deshalb nicht zurückgesetzt werden
; |3 - Zu einem Handle wurde eine Funktion zugeordnet, zuordnung einer Funktion zu NotifyCode nicht möglich.
;; Author ........: Raupi @ Autoit.de
; Modified.......:
; Remarks .......: Zugeordnete Funktionen müssen den Parameterkopf $hWndFrom, $iIDFrom, $iNotifyCode, $wParam, $lParam haben
;; Wenn Parameter $iNotifyCode und $Function nicht gesetzt sind, werden die dem Handle($ihWnd) gehörenden Zuordnungen gelöscht.
; Wenn per iNotifyCode = "Func" einem Handle eine Funktion zugeordnet wurde, werden Zuordnungen einer Funktion, zu einem NotifyCode für diese Handle ignoriert.
; Wird per NotifyCode = "Func" einem Handle eine Funktion zugeordnet, dann werden alle Funktionszuordnungen zu den NotifyCodes für dieses Handle gelöscht.
; ================================================================================================================================================================================
Func _Notify_SetNotifytoFunc($hWnd, $iNotifyCode = "", $Function = "");
Local $NewArray[1][2], $iResultHandle, $TempArray, $iCount, $iResultNotifyCode, $TempCopyArray[1]
If Not IsHWnd($hWnd) Then
$hWnd = GUICtrlGetHandle($hWnd)
If $hWnd = 0 Then Return SetError(1, 0, -1)
EndIf
For $i = 0 To UBound($aNotifyHwnd, 1) - 1
If $aNotifyHwnd[$i][0] = $hWnd Then $iResultHandle = $i
Next
If $iResultHandle = 0 Then
If $iNotifyCode = "" And $Function = "" Then Return SetError(2, 0, -1)
$iCount = UBound($aNotifyHwnd, 1)
ReDim $aNotifyHwnd[$iCount + 1][2]
$aNotifyHwnd[$iCount][0] = $hWnd
$aNotifyHwnd[$iCount][1] = $NewArray
$aNotifyHwnd[0][0] = $iCount
$iResultHandle = $iCount
ElseIf $iResultHandle <> 0 And $iNotifyCode = "" And $Function = "" Then
ReDim $TempCopyArray[UBound($aNotifyHwnd, 1) - 1][2]
For $i = 0 To $iResultHandle - 1
$TempCopyArray[$i][0] = $aNotifyHwnd[$i][0]
$TempCopyArray[$i][1] = $aNotifyHwnd[$i][1]
Next
For $i = $iResultHandle + 1 To UBound($aNotifyHwnd, 1) - 1
$TempCopyArray[$i - 1][0] = $aNotifyHwnd[$i][0]
$TempCopyArray[$i - 1][1] = $aNotifyHwnd[$i][1]
Next
$TempCopyArray[0][0] = UBound($aNotifyHwnd, 1) - 2
$aNotifyHwnd = $TempCopyArray
Return 1
EndIf
$TempArray = $aNotifyHwnd[$iResultHandle][1]
If $iNotifyCode = "Func" And $Function <> "" Then
ReDim $TempArray[2][3]
$TempArray[1][0] = "Func"
$TempArray[1][1] = $Function
$TempArray[0][0] = 1
$aNotifyHwnd[$iResultHandle][1] = $TempArray
Return 1
EndIf
For $i = 0 To UBound($TempArray, 1) - 1
If $TempArray[$i][0] = "Func" Then Return SetError(3, 0, -1)
If $TempArray[$i][0] = $iNotifyCode Then $iResultNotifyCode = $i
Next
If $iResultNotifyCode = 0 Then
$iCount = UBound($TempArray, 1)
ReDim $TempArray[$iCount + 1][2]
$TempArray[$iCount][0] = $iNotifyCode
$TempArray[$iCount][1] = $Function
$TempArray[0][0] = $iCount
$aNotifyHwnd[$iResultHandle][1] = $TempArray
ElseIf $iResultNotifyCode <> 0 And $Function = "" Then
ReDim $TempCopyArray[UBound($TempArray, 1) - 1][2]
For $i = 0 To $iResultNotifyCode - 1
$TempCopyArray[$i][0] = $TempArray[$i][0]
$TempCopyArray[$i][1] = $TempArray[$i][1]
Next
For $i = $iResultNotifyCode + 1 To UBound($TempArray, 1) - 1
$TempCopyArray[$i - 1][0] = $TempArray[$i][0]
$TempCopyArray[$i - 1][1] = $TempArray[$i][1]
Next
$TempCopyArray[0][0] = UBound($TempArray, 1) - 2
$aNotifyHwnd[$iResultHandle][1] = $TempCopyArray
Return 1
ElseIf $iResultNotifyCode <> 0 And $Function <> "" Then
$TempArray[$iResultNotifyCode][1] = $Function
$aNotifyHwnd[$iResultHandle][1] = $TempArray
EndIf
EndFunc ;==>_SetFunc_Notify
; #FUNCTION# ====================================================================================================================
; Name...........: _StartUp_Notify
; Description ...: Registriert WM_NOTIFY
; Syntax.........: _StartUp_Notify($bStartStop = True)
; Parameters ....: $bStartStop - Starten = True, Stoppen = False, Default ist True
; ;
; Return values .: Success - 1
; Failure - -1, sets @error to:
; |1 - Parameter nicht True oder False
; |2 - Es wurden noch keine Funktionen zugeordnet.
;
;; Author ........: Raupi @ Autoit.de
; Modified.......:
; Remarks .......:
; ===============================================================================================================================
Func _StartUp_Notify($bStartStop = True);
If Not IsBool($bStartStop) Then Return SetError(1, 0, -1)
If $aNotifyHwnd[0][0] < 1 Then Return SetError(2, 0, -1)
If $bStartStop = True Then
GUIRegisterMsg($UDF_WM_NOTIFY, "UDF_NOTIFY_HANDLER")
If @error Then SetError(3, 0, -1)
Else
GUIRegisterMsg($UDF_WM_NOTIFY, "")
EndIf
Return 1
EndFunc ;==>_StartUp_Notify
Func UDF_NOTIFY_HANDLER($hWnd, $Msg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $Func = "", $temp, $sBuffer
Local $TempLparam =$lparam
If $sExtNotify<>"" Then
Call ($sExtNotify,$hWnd, $Msg, $wParam, $lParam)
If @error = 0xDEAD And @extended = 0xBEEF Then ConsoleWrite("Function does not exist or invalid number of parameters" & @CRLF)
EndIf
$tNMHDR = DllStructCreate($UDF_tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
For $i = 1 To $aNotifyHwnd[0][0]
If $aNotifyHwnd[$i][0] = $hWndFrom Then
$temp = $aNotifyHwnd[$i][1]
If $temp[1][0] = "Func" Then
$Func = $temp[1][1]
ExitLoop
EndIf
For $i = 1 To $temp[0][0]
If $temp[$i][0] = $iCode Then $Func = $temp[$i][1]
Next
EndIf
Next
If $Func <> "" Then
Call($Func,$hWndFrom, $iIDFrom, $iCode,$wParam,$lParam)
If @error = 0xDEAD And @extended = 0xBEEF Then ConsoleWrite("Function does not exist or invalid number of parameters" & @CRLF)
Return 'GUI_RUNDEFMSG'
EndIf
Return 'GUI_RUNDEFMSG'
EndFunc ;==>UDF_NOTIFY_HANDLER