Code : Tout sélectionner
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=favicon.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;==[ Création ]========: xx/xx/20xx
;==[ Auteur ]==========: xxxxxxxxxxxxxxxxxxxxxxx
;==[ Service ]=========: xxxxxxxxxxxxxxxxxxxxxxx
;==[ Description ]=====: ************************************
;==[ Modification ]====: Dernière modification le xx/xx/20xx
;==[ Nature modification ]====:
;==[xx/xx/20xx: ***********************************]========
;==[Include]====
#include <GuiStatusBar.au3>
#include <Timers.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Color.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <File.au3>
#include <ArrayEx.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <WinNet.au3>
#include <ComboConstants.au3>
#include <GuiComboBox.au3>
#include <GuiComboBoxEx.au3>
#include <ColorConstantS.au3>
#include <String.au3>
#include <EditConstants.au3>
Opt("GUIOnEventMode", 1)
;==[Variables globales & autres]====
Global $ApplicationName = "__________", $Version = "V_._._", $CreationDate = "xx/xx/20xx", $NumberOfModification = "", $LastModification = "", $Area
Global $hStatus, $aParts[4] = [200, 450, 480, 200], $aGuiPos, $iMemo, $c_Station, $TrendCurveGUI=9999, $label, $c_TypeOfProcess, $l_Line, $c_OutilRetire
Global $hGUI, $hFile, $hLineChoice, $hHelp
Global Enum $e_idNew = 1000, $e_idAbout, $e_idExit, $e_idHowTo, $e_idStatSertissage, $e_idStatTest, $e_idStatVissage
Global $hListView
$LineFile = @ScriptDir & "\ini\MenuAutoTest.ini"
$IniFilePath = @ScriptDir & "\ini\cellsTest.ini"
$IniMesurePoint = @ScriptDir & "\ini\MesurePointTest.ini"
$IniTypeOfProcess = @ScriptDir & "\ini\TypeOfProcessTest.ini"
$IniTroubleShooting = @ScriptDir & "\ini\TroubleShootingTest.ini"
;==[Programme]====
_Main()
AdlibRegister("_ScreenAdaptation")
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_TIMER, "WM_TIMER")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUIRegisterMsg($WM_DRAWITEM, "_WM_DRAWITEM")
$iTimer = _Timer_SetTimer($hGUI, 1000)
While GUIGetMsg() <> -3
WEnd
Func _Main()
Global $iColorResult = 0x000FF0
$hGUI = GUICreate($ApplicationName & " - Powered By __________. Version: " & $Version, @DesktopWidth - 100, @DesktopHeight - 100, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quitter", $hGUI)
$hFile = _GUICtrlMenu_CreateMenu()
$New= GUICtrlCreateMenuItem("Nouveau" & @TAB & "Ctrl+N", $hFile)
_GUICtrlMenu_AddMenuItem($hFile, "Fermer l'application", $e_idExit)
$hStatistiques = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_AddMenuItem($hStatistiques, "xxx", $e_idStatSertissage)
_GUICtrlMenu_AddMenuItem($hStatistiques, "yyy", $e_idStatTest)
_GUICtrlMenu_AddMenuItem($hStatistiques, "zzz", $e_idStatVissage)
$hLineChoice = _GUICtrlMenu_CreateMenu()
Global $ReadSection = IniReadSection($LineFile, "LineName")
Global $IDMenu[$ReadSection[0][0]]
For $j = 1 To $ReadSection[0][0]
_GUICtrlMenu_InsertMenuItem($hLineChoice, $j - 1 , "&" & $ReadSection[$j][1], 1100 + ($j - 1))
$IDMenu[$j-1] = 1100 + ($j - 1)
Next
$hHelp = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_AddMenuItem($hHelp, "&A propos", $e_idAbout)
_GUICtrlMenu_AddMenuItem($hHelp, "&Comment utiliser " & $ApplicationName & "?", $e_idHowTo)
; Create Main menu
Global $hMain = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_AddMenuItem($hMain, "&Fichier", 0, $hFile)
_GUICtrlMenu_AddMenuItem($hMain, "&Choix de la ligne", 1, $hLineChoice)
_GUICtrlMenu_AddMenuItem($hMain, "&Statistiques", 2, $hStatistiques)
_GUICtrlMenu_AddMenuItem($hMain, "&?", 3, $hHelp)
$hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $SBARS_SIZEGRIP)
;==[StatusBar]==============================
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hStatus, "wstr", 0, "wstr", 0)
$hIcons = _WinAPI_LoadShell32Icon(265)
_GUICtrlStatusBar_SetIcon($hStatus, 0, $hIcons)
$hIcons2 = _WinAPI_LoadShell32Icon(160)
_GUICtrlStatusBar_SetIcon($hStatus, 1, $hIcons2)
_GUICtrlStatusBar_SetText($hStatus, "Utilisateur: " & StringUpper(@UserName) & " " & "Poste: " & @ComputerName, 1)
_GUICtrlMenu_SetMenu($hGUI, $hMain)
;==[Corps du GUI]===========================
$l_Line = GUICtrlCreateLabel("Choisir la ligne dans le menu", 10, 4, 200, 20)
GUICtrlSetFont(-1, 12, 400)
GUICtrlSetColor(-1, $COLOR_RED)
$l_Station = GUICtrlCreateLabel("Station", 10, 30, 200, 20)
GUICtrlSetFont(-1, 12, 400)
$c_Station = GUICtrlCreateCombo("", 10, 50, 270, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
$l_Outil = GUICtrlCreateLabel("Type outillage", 10, 80, 200, 20)
GUICtrlSetFont(-1, 12, 400)
$c_TypeOfProcess = GUICtrlCreateCombo("", 10, 100, 270, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
$l_OutilRetire = GUICtrlCreateLabel("Outillage retiré", 10, 130, 200, 20)
GUICtrlSetFont(-1, 12, 400)
$c_OutilRetire = GUICtrlCreateCombo("", 10, 150, 270, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
$l_NatureDefaut = GUICtrlCreateLabel("Défaut affiché/constaté", 10, 325, 200, 20)
GUICtrlSetFont(-1, 12, 400)
$hListView = GUICtrlCreateListView("", 10, 200, 300, 110)
_GUICtrlListView_InsertColumn($hListView, 0, "Nature du défaut", 170)
$Input1 = GUICtrlCreateInput("", 10, 345, 300, 100, BitOR($ES_MULTILINE, $ES_WANTRETURN))
My_GUICtrlListView_AutoSizeColumns($hListView)
GUISetState(@SW_SHOW)
EndFunc
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $lParam
$itemID = _WinAPI_LoWord($wParam)
Select
Case $itemID = $e_idStatSertissage
MsgBox(64, $ApplicationName, "Coming soon jeune " & @UserName, 0, $hGUI)
Case $itemID = $e_idStatTest
MsgBox(64, $ApplicationName, "Coming soon jeune " & @UserName, 0, $hGUI)
Case $itemID = $e_idStatVissage
MsgBox(64, $ApplicationName, "Coming soon jeune " & @UserName, 0, $hGUI)
Case $itemID = $e_idExit
Exit
Case ($itemID >= 1100) And ($itemID <> $e_idExit)
Global $ReadSection2 = IniReadSection($IniFilePath, $ReadSection[$itemID - 1099][0])
Global $Value = $ReadSection[$itemID - 1099][1]
Global $Key = $ReadSection[$itemID - 1099][0]
Global $Key2 = $ReadSection2[$itemID - 1099][0]
If Not @error Then
_GUICtrlListView_DeleteAllItems($hListView)
_LoadCells()
Else
GUICtrlSetData($label, "")
EndIf
EndSelect
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Func _LoadCells()
_GUICtrlListView_DeleteAllItems($hListView)
GUICtrlSetData($l_Line, "", "")
GUICtrlSetData($c_Station, "", "")
GUICtrlSetData($c_OutilRetire, "", "")
GUICtrlSetData($c_TypeOfProcess, "", "")
$l_Line = GUICtrlCreateLabel($Value, 10, 4, 200, 20)
GUICtrlSetFont($l_Line, 12, 400)
GUICtrlSetColor(-1, $COLOR_BLUE)
For $j = 1 To $ReadSection2[0][0]
GUICtrlSetData($c_Station, $ReadSection2[$j][0] & " " & $ReadSection2[$j][1])
Next
GUISetState()
GUICtrlSetOnEvent($c_Station, "_LoadTypeOfProcess")
EndFunc
Func _LoadMesurePoint()
_GUICtrlListView_DeleteAllItems($hListView)
$SplitHelp = StringSplit(GUICtrlRead($c_Station), " ")
Global $Section_LTOP_Help = StringLeft($Key, 5) & $SplitHelp[1]
$ReadSectionMP_Help = IniReadSection($IniMesurePoint, $Section_LTOP_Help)
If @error Then
_GUICtrlListView_DeleteAllItems($hListView)
Return
EndIf
For $j = 1 To $ReadSectionMP_Help[0][0]
_GUICtrlListView_AddItem($hListView, $ReadSectionMP_Help[$j][1])
Next
EndFunc
Func _LoadTypeOfProcess()
GUICtrlSetData($c_TypeOfProcess, "")
GUICtrlSetData($c_OutilRetire, "")
$split = StringSplit(GUICtrlRead($c_Station), " ")
Global $Section_LTOP = $Key & "_" & $split[1]
$ReadSectionMP3 = IniReadSection($IniTypeOfProcess, $Section_LTOP)
If @error Then Return
For $j = 1 To $ReadSectionMP3[0][0]
GUICtrlSetData($c_TypeOfProcess, $ReadSectionMP3[$j][0])
Next
_LoadMesurePoint()
GUICtrlSetOnEvent($c_TypeOfProcess, "_LoadOutilRetire")
EndFunc
Func _LoadOutilRetire()
$ReadSectionMP4 = IniReadSection($IniTypeOfProcess, $Section_LTOP)
Global $toto = ""
GUICtrlSetData($c_OutilRetire, "")
If Not @error Then
For $i = 1 To $ReadSectionMP4[0][0]
If $ReadSectionMP4[$i][0] = GUICtrlRead($c_TypeOfProcess) Then
GUICtrlSetData($c_OutilRetire, $ReadSectionMP4[$i][1])
EndIf
Next
EndIf
EndFunc
Func _WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam, $lParam
Local $tDRAWITEMSTRUCT = DllStructCreate("uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;HWND hwndItem;HANDLE hDC;long rcItem[4];ULONG_PTR itemData", $lParam)
Local $itemID = DllStructGetData($tDRAWITEMSTRUCT, "itemID")
Local $hDC = DllStructGetData($tDRAWITEMSTRUCT, "hDC")
Local $tRect = DllStructCreate("long left;long top;long right; long bottom", DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem"))
Local $iTop = DllStructGetData($tRect, "top")
Local $iLeft = DllStructGetData($tRect, "left")
Local $hBrush
Switch $itemID
;Case 0
;$hBrush = _WinAPI_CreateSolidBrush(0xFFFF00)
; _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)
;_WinAPI_SetBkMode($hDC, $TRANSPARENT)
;DllStructSetData($tRect, "top", $iTop + 1)
;DllStructSetData($tRect, "left", $iLeft + 1)
;_WinAPI_DrawText($hDC, "Part 1", $tRect, $DT_LEFT)
;_WinAPI_DeleteObject($hBrush)
;Case 1
;$hBrush = _WinAPI_CreateSolidBrush(0x00FF00)
;_WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)
;_WinAPI_SetBkMode($hDC, $TRANSPARENT)
;DllStructSetData($tRect, "top", $iTop + 1)
;DllStructSetData($tRect, "left", $iLeft + 1)
;_WinAPI_DrawText($hDC, "Part 2", $tRect, $DT_LEFT)
;_WinAPI_DeleteObject($hBrush)
Case 2
$hBrush = _WinAPI_CreateSolidBrush($iColorResult)
_WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrush)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
DllStructSetData($tRect, "top", $iTop + 1)
DllStructSetData($tRect, "left", $iLeft + 1)
;_WinAPI_DrawText($hDC, "Part 3", $tRect, $DT_LEFT)
_WinAPI_DeleteObject($hBrush)
EndSwitch
$tDRAWITEMSTRUCT = 0
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_DRAWITEM
Func _ScreenAdaptation()
$WorkAera = _GetWorkArea() ;Etait Local $WorkAera = _GetWorkArea() et non Global
Local $aGuiPos = WinGetPos($hGui)
;If WinExists($MachDatGUI) Then
If $aGuiPos[0] <> $WorkAera[0] OR $aGuiPos[1] <> $WorkAera[1] OR $aGuiPos[2] <> $WorkAera[4] OR $aGuiPos[3] <> $WorkAera[5] Then WinMove($hGui, "", $WorkAera[0]+4, $WorkAera[1]+4, $WorkAera[4] - 8, $WorkAera[5] - 8)
;EndIf
EndFunc
Func _GetWorkArea()
global $Area[6]
Local $StartRect = DllStructCreate("int[4]")
Local $PStartRect = DllStructGetPtr($StartRect)
DllCall("user32.dll", "int", "SystemParametersInfo", "int", 48, "int", 0, "ptr", $PStartRect, "int", 0)
$Area[0] = DllStructGetData($StartRect,1,1)
$Area[1] = DllStructGetData($StartRect,1,2)
$Area[2] = DllStructGetData($StartRect,1,3)
$Area[3] = DllStructGetData($StartRect,1,4)
$Area[4] = $Area[2] - $Area[0]
$Area[5] = $Area[3] - $Area[1]
Return $Area
EndFunc
Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $ilParam
Switch _Timer_GetTimerID($iwParam)
Case $iTimer
_UpdateStatusBarClock()
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_TIMER
Func _UpdateStatusBarClock()
_GUICtrlStatusBar_SetText($hStatus, @TAB & StringFormat(_NowDate() & " " & "%02d:%02d:%02d", @HOUR, @MIN, @SEC), 0)
EndFunc
Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam, $ilParam
_GUICtrlStatusBar_Resize($hStatus)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
Func _Quitter()
Exit
EndFunc
Func My_GUICtrlListView_AutoSizeColumns($hListView, $iMini = 10)
If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView)
Local $hHeader = _GUICtrlListView_GetHeader($hListView), $iHeader_Width, $iData_Width
_GUICtrlListView_BeginUpdate($hListView)
For $iIndex = 0 To _GUICtrlListView_GetColumnCount($hListView) - 1
If _GUICtrlListView_GetColumnWidth($hListView, $iIndex) = 0 Then ContinueLoop
_GUICtrlListView_SetColumnWidth($hListView, $iIndex, $LVSCW_AUTOSIZE_USEHEADER)
$iHeader_Width = _GUICtrlListView_GetColumnWidth($hListView, $iIndex)
If @OSVersion = "WIN_XP" And $iIndex < _GUICtrlListView_GetColumnCount($hListView) - 1 Then
If _GUICtrlHeader_GetItemFlags($hHeader, $iIndex) / 2 > 1 Then $iHeader_Width += 30
EndIf
_GUICtrlListView_SetColumnWidth($hListView, $iIndex, $LVSCW_AUTOSIZE)
$iData_Width = _GUICtrlListView_GetColumnWidth($hListView, $iIndex)
If $iHeader_Width > $iData_Width Then
_GUICtrlListView_SetColumnWidth($hListView, $iIndex, $iHeader_Width)
EndIf
If _GUICtrlListView_GetColumnWidth($hListView, $iIndex) < $iMini Then
_GUICtrlListView_SetColumnWidth($hListView, $iIndex, $iMini)
EndIf
Next
_GUICtrlListView_EndUpdate($hListView)
EndFunc ;==>My_GUICtrlListView_AutoSizeColumns