#AutoIt3Wrapper_UseX64=Y #include #include #include "GUIListViewEx.au3" #include #include #include #include #include Opt("GUIOnEventMode", 1) Global $g_hGUI1, $g_hGUI2, $g_idButton1, $g_idButton2, $g_idButton3 Global $hListViewDatascope,$hDatabaseScope,$Button1,$Button2;a utiliser pour l'affichage de la 2eme fenetre Global $iEditMode = 0 gui1() Func gui1() $g_hGUI1 = GUICreate("GUI 1", 200, 200, 100, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function $g_idButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30) GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function $g_idButton2 = GUICtrlCreateButton("Show GUI 2", 10, 60, 80, 30) GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function $g_idButton3 = GUICtrlCreateButton("Traitement", 10, 100, 80, 30) GUICtrlSetOnEvent(-1, "Traitement_intermediaire") ; Call a traitement GUISetState() While 1 Sleep(10) WEnd EndFunc ;==>gui1 Func gui2() $g_hGUI2 = GUICreate("GUI 2", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function $g_idButton3 = GUICtrlCreateButton("GoOn", 10, 450, 100, 30) GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function $g_idButton4 = GUICtrlCreateButton("Cancel", 250, 450, 100, 30) GUICtrlSetOnEvent(-1, "Off_Button") ; Call a common button function $hListViewDatascope = GUICtrlCreateListView("Tom|Dick|Harry", 10, 10, 400, 400, $LVS_SHOWSELALWAYS) _GUICtrlListView_SetExtendedListViewStyle($hListViewDatascope, BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES)) _GUICtrlListView_SetColumnWidth($hListViewDatascope, 0, 93) _GUICtrlListView_SetColumnWidth($hListViewDatascope, 1, 93) _GUICtrlListView_SetColumnWidth($hListViewDatascope, 2, 93) ; Set font GUICtrlSetFont($hListViewDatascope, 12, Default, Default, "Courier New") ; Note edit control will use same font ; Create array and fill listview Global $aLV_List[20] For $i = 0 To UBound($aLV_List) - 1 If Mod($i, 5) Then $aLV_List[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i Else $aLV_List[$i] = "Tom " & $i & "||Harry " & $i EndIf GUICtrlCreateListViewItem($aLV_List[$i], $hListViewDatascope) Next ;_GUIListViewEx_Init($hLV, $aArray = "", $iStart = 0, $iColour = 0, $fImage = False, $iAdded = 0) $iLVIndex_1 = _GUIListViewEx_Init($hListViewDatascope,$aLV_List,0,0,true,+1+4); Tri & modification possible ;_GUIListViewEx_SetEditStatus($iLV_Index, $vCol, $iMode = 1, $vParam1 = Default, $vParam2 = Default) _GUIListViewEx_SetEditStatus($iLVIndex_1,"1;2");modification des colonnes 1 & 2 _GUIListViewEx_SetActive($iLVIndex_1) ; Enregistrement des messages Windows _GUIListViewEx_MsgRegister(Default) GUIRegisterMsg($WM_NOTIFY, "_Events_WM_NOTIFY") GUISetState() EndFunc ;==>gui2 Func On_Close() Switch @GUI_WinHandle ; See which GUI sent the CLOSE message Case $g_hGUI1 Exit ; If it was this GUI - we exit <<<<<<<<<<<<<<< Case $g_hGUI2 GUIDelete($g_hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<< GUICtrlSetState($g_idButton2, $GUI_ENABLE) EndSwitch EndFunc ;==>On_Close Func Off_Button() On_Close() EndFunc Func On_Button() Switch @GUI_CtrlId ; See which button sent the message Case $g_idButton1 MessageBox(1) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<< Case $g_idButton2 GUICtrlSetState($g_idButton2, $GUI_DISABLE) gui2() Case $g_idButton3 MessageBox(2) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<< EndSwitch EndFunc ;==>On_Button Func MessageBox($iIndex) MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex) EndFunc ;==>MessageBox Func Traitement_intermediaire() gui2(); display the listview MsgBox(0,"Suite","cela continue");suite du script ;.... EndFunc Func _Events_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $Msg, $wParam, $lParam) Local $tInfo, $Code $tInfo = DllStructCreate($tagNMHDR, $lParam) $hWnd = HWnd(DllStructGetData($tInfo, "hWndFrom")) $Code = DllStructGetData($tInfo, "Code") $hWnd_ListViewDatascope=GUICtrlGetHandle($hListViewDatascope) If $hWnd = $hWnd_ListViewDatascope Then Switch $Code Case $NM_DBLCLK ; Double-clic sur un élément de la ListView Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $iIndex = DllStructGetData($tInfo, "Index"); indique le numero de ligne Local $iSubItem = DllStructGetData($tInfo, "SubItem");indique le numero de colonne Local $sText = _GUICtrlListView_GetItemText($hListViewDatascope, $iIndex, $iSubItem) $vRet = _GUIListViewEx_EventMonitor($iEditMode) MsgBox(0,"valeur click","$iSubItem :"&$iSubItem&@CRLF&"$iIndex:"&$iIndex&@CRLF&"$sText:"&$sText&@CRLF&$vRet&@CRLF&"ret:&$ret");&@CRLF&"$hEdit:"&$hEdit) Case $NM_RCLICK ; right button Local $aSelected = _GUICtrlListView_GetSelectedIndices($hWnd, True) If $aSelected[0] > 0 Then MsgBox(0,"test","Right Button") EndIf EndSwitch Return $GUI_RUNDEFMSG ; EndIf ; Must be LAST line of the handler Return(_GUIListViewEx_WM_NOTIFY_Handler($hWnd, $Msg, $wParam, $lParam)) EndFunc