Что нового

Не работает одновременно вызов двух функций через GUIRegisterMsg

Centrinar

Новичок
Сообщения
100
Репутация
1
В скрипте две функции вызываються с помощью GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') и GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY2'). Работает только одна, как обойти?
 

Yashied

Модератор
Команда форума
Глобальный модератор
Сообщения
5,379
Репутация
2,724
Можно зарегистрировать лишь одну функцию, и этого вполне достаточно.
 
Автор
C

Centrinar

Новичок
Сообщения
100
Репутация
1
А как их тогда объединить подскажите пожалуйста :IL_AutoIt_1:
Код:
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
	Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

	$hWndListView = $hListView
	If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

	$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
	$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
	$iCode = DllStructGetData($tNMHDR, 'Code')

	Switch $hWndFrom
		Case $hWndListView
			Switch $iCode
				Case $NM_RCLICK
					If $fEdit Then
						_Editor_LV_Save()
					EndIf
					$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
					$iIndexItem = DllStructGetData($tInfo, 'Index')
					$iIndexSubItem = DllStructGetData($tInfo, 'SubItem')
					If $iIndexSubItem <> -1 Then
						$iLast_LV_SubIndex = $iIndexSubItem
					EndIf
					If $iIndexItem <> -1 Then
						$iLast_LV_Index = $iIndexItem
						For $i = 0 To $iCountRow
							GUICtrlSetState($aChangeSubMenu[$i], $GUI_ENABLE)
						Next
						GUICtrlSetState($aChangeSubMenu[$iIndexItem], $GUI_DISABLE)
						ShowMenu($hWnd, $nContextMenu, $hListView, 1)
					EndIf
				Case $NM_DBLCLK
					$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
					$iIndexItem = DllStructGetData($tInfo, 'Index')
					$iIndexSubItem = DllStructGetData($tInfo, 'SubItem')
					If $iIndexSubItem <> -1 Then
						$iLast_LV_SubIndex = $iIndexSubItem
					EndIf
					If $iIndexItem <> -1 Then
						$iLast_LV_Index = $iIndexItem
					EndIf
					If Not $fEdit Then
						_Editor_LV_Show()
					EndIf
				Case $NM_CLICK, $NM_KILLFOCUS, $LVN_COLUMNCLICK
					If $fEdit Then
						_Editor_LV_Save()
					EndIf
			EndSwitch
	EndSwitch
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Func WM_NOTIFY2($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview, $fChecked
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
    $iCode = DllStructGetData($tNMHDR, 'Code')
    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
				Case $NM_CUSTOMDRAW
			         For $i = 1 To $a_hItem[0][0]
                        $a_hItem[$i][$a_hItem[0][1] + 2] = _GUICtrlTreeView_GetChecked($hWndFrom, $a_hItem[$i][0])
                        If $a_hItem[$i][$a_hItem[0][1] + 1] <> $a_hItem[$i][$a_hItem[0][1] + 2] Then
                            $a_hItem[$i][$a_hItem[0][1] + 1] = $a_hItem[$i][$a_hItem[0][1] + 2]
                            For $j = 1 To $a_hItem[0][1]
                                If $a_hItem[$i][$j] = True Then

                                    _GUICtrlTreeView_SetChecked($hWndFrom, $a_hItem[$i][$j], $a_hItem[$i][$a_hItem[0][1] + 1])

                                EndIf
                            Next
                        EndIf
                    Next
                    Return 0
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Centrinar
Попробуйте так:
Код:
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
	Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $hWndTreeview, $fChecked

	$hWndListView = $hListView
	If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
	$hWndTreeview = $hTreeView
	If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
	$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
	$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
	$iCode = DllStructGetData($tNMHDR, 'Code')
	Switch $hWndFrom
		Case $hWndListView
			Switch $iCode
				Case $NM_RCLICK
					If $fEdit Then
						_Editor_LV_Save()
					EndIf
					$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
					$iIndexItem = DllStructGetData($tInfo, 'Index')
					$iIndexSubItem = DllStructGetData($tInfo, 'SubItem')
					If $iIndexSubItem <> -1 Then
						$iLast_LV_SubIndex = $iIndexSubItem
					EndIf
					If $iIndexItem <> -1 Then
						$iLast_LV_Index = $iIndexItem
						For $i = 0 To $iCountRow
							GUICtrlSetState($aChangeSubMenu[$i], $GUI_ENABLE)
						Next
						GUICtrlSetState($aChangeSubMenu[$iIndexItem], $GUI_DISABLE)
						ShowMenu($hWnd, $nContextMenu, $hListView, 1)
					EndIf
				Case $NM_DBLCLK
					$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
					$iIndexItem = DllStructGetData($tInfo, 'Index')
					$iIndexSubItem = DllStructGetData($tInfo, 'SubItem')
					If $iIndexSubItem <> -1 Then
						$iLast_LV_SubIndex = $iIndexSubItem
					EndIf
					If $iIndexItem <> -1 Then
						$iLast_LV_Index = $iIndexItem
					EndIf
					If Not $fEdit Then
						_Editor_LV_Show()
					EndIf
				Case $NM_CLICK, $NM_KILLFOCUS, $LVN_COLUMNCLICK
					If $fEdit Then
						_Editor_LV_Save()
					EndIf
			EndSwitch
		Case $hWndTreeview
			Switch $iCode
				Case $NM_CUSTOMDRAW
					For $i = 1 To $a_hItem[0][0]
						$a_hItem[$i][$a_hItem[0][1] + 2] = _GUICtrlTreeView_GetChecked($hWndFrom, $a_hItem[$i][0])
						If $a_hItem[$i][$a_hItem[0][1] + 1] <> $a_hItem[$i][$a_hItem[0][1] + 2] Then
							$a_hItem[$i][$a_hItem[0][1] + 1] = $a_hItem[$i][$a_hItem[0][1] + 2]
							For $j = 1 To $a_hItem[0][1]
								If $a_hItem[$i][$j] = True Then
									_GUICtrlTreeView_SetChecked($hWndFrom, $a_hItem[$i][$j], $a_hItem[$i][$a_hItem[0][1] + 1])
								EndIf
							Next
						EndIf
					Next
			EndSwitch
	EndSwitch
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
 
Автор
C

Centrinar

Новичок
Сообщения
100
Репутация
1
Madmasles - как всегда большое спасибо! :IL_AutoIt_1:
 
Верх