Что нового

Как обьединить две функии WM_NOTIFY ?

cracker24

Новичок
Сообщения
6
Репутация
0
Здравствуйте помогите объединить две функции WM_NOTIFY.


Первая функция
Код:
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 ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $iIndex = DllStructGetData($tInfo, "Index")
                   
                    If $iIndex <> -1 Then
                        $iLast_LV_Index = $iIndex
                        ShowMenu($hWnd, $ContextMenu, $hListView, 1)
                    EndIf
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc


Вторая функция
Код:
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    Local $tNMIA = DllStructCreate($tagNMITEMACTIVATE, $lParam)
    Local $hTarget = DllStructGetData($tNMIA, 'hWndFrom')
    Local $ID = DllStructGetData($tNMIA, 'Code')

    Switch $hWnd
        Case $hTool
            Switch $hTarget
                Case $hToolbar
                    Switch $ID
                        Case $TBN_GETINFOTIPW

;~                          Local $tNMTBGIT = DllStructCreate($tagNMTBGETINFOTIP, $lParam)
                            Local $tNMTBGIT = DllStructCreate($tagNMHDR & ';ptr Text;int TextMax;int Item;lparam lParam;', $lParam)
                            Local $Item = DllStructGetData($tNMTBGIT, 'Item')
                            Local $Text = ''

                            Switch $Item
                                Case 10000 ; Button 1
                                    $Text = 'Tooltip 1'
                                Case 10001 ; Button 2
                                    $Text = 'Tooltip 2'
                                Case 10002 ; Button 3
                                    $Text = 'Tooltip 3'
                                Case 10003 ; Button 4
                                    $Text = 'Tooltip 4'
                                Case 10004 ; Button 5
                                    $Text = 'Tooltip 5'
                                Case Else

                            EndSwitch
                            If $Text Then
                                DllStructSetData(DllStructCreate('wchar[' & DllStructGetData($tNMTBGIT, 'TextMax') & ']', DllStructGetData($tNMTBGIT, 'Text')), 1, $Text)
                            EndIf
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Код:
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")
	
	Local $tNMIA = DllStructCreate($tagNMITEMACTIVATE, $lParam)
	Local $hTarget = DllStructGetData($tNMIA, 'hWndFrom')
	Local $ID = DllStructGetData($tNMIA, 'Code')
	
	Switch $hWndFrom
		Case $hWndListView
			Switch $iCode
				Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
					$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
					$iIndex = DllStructGetData($tInfo, "Index")
					
					If $iIndex <> -1 Then
						$iLast_LV_Index = $iIndex
						ShowMenu($hWnd, $ContextMenu, $hListView, 1)
					EndIf
			EndSwitch
	EndSwitch
	
	Switch $hWnd
		Case $hTool
			Switch $hTarget
				Case $hToolbar
					Switch $ID
						Case $TBN_GETINFOTIPW
;~                          Local $tNMTBGIT = DllStructCreate($tagNMTBGETINFOTIP, $lParam)
							Local $tNMTBGIT = DllStructCreate($tagNMHDR & ';ptr Text;int TextMax;int Item;lparam lParam;', $lParam)
							Local $Item = DllStructGetData($tNMTBGIT, 'Item')
							Local $Text = ''
							
							Switch $Item
								Case 10000 ; Button 1
									$Text = 'Tooltip 1'
								Case 10001 ; Button 2
									$Text = 'Tooltip 2'
								Case 10002 ; Button 3
									$Text = 'Tooltip 3'
								Case 10003 ; Button 4
									$Text = 'Tooltip 4'
								Case 10004 ; Button 5
									$Text = 'Tooltip 5'
								Case Else
									
							EndSwitch
							If $Text Then
								DllStructSetData(DllStructCreate('wchar[' & DllStructGetData($tNMTBGIT, 'TextMax') & ']', DllStructGetData($tNMTBGIT, 'Text')), 1, $Text)
							EndIf
					EndSwitch
			EndSwitch
	EndSwitch
	
	Return $GUI_RUNDEFMSG
EndFunc
 

gregaz

AutoIT Гуру
Сообщения
1,166
Репутация
299
Вариант последовательной обработки сообщений двух ф-ий WM_NOTIFY

Код:
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')

; .............................................................

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
       
    Local $Result = TV_WM_NOTIFY_1($hWnd, $iMsg, $wParam, $lParam)
    If $Result <> $GUI_RUNDEFMSG Then Return $Result
   
     Local $hWndFrom,  $iCode, $tNMHDR, $hWndListView, $tInfo 
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

	;..............................................................
	
	 Return $GUI_RUNDEFMSG
EndFunc


Func WM_NOTIFY_1($hWnd, $iMsg, $wParam, $lParam)

    Local $tNMIA = DllStructCreate($tagNMITEMACTIVATE, $lParam)
    Local $hTarget = DllStructGetData($tNMIA, 'hWndFrom')
    Local $ID = DllStructGetData($tNMIA, 'Code')

	; ..................................................
    
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
 
Верх