J'utilise un fichier *.ini pour stocker le chemin d'enregistrement de données (modifiable par l'utilisateur).
J'arrive à le modifier, mais je n'arrive pas à rafraichir ou relire le fichier *.ini lorsque celui-ci est modifié..
Si quelqu'un à une idée...
Merci par avance, ci-joint mon code
► Afficher le texte
Code : Tout sélectionner
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)
;==[Include]====
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#Include <File.au3>
#include <Array.au3>
#include <SliderConstants.au3>
#include <ListviewConstants.au3>
#include <ScreenCapture.au3>
#include <Timers.au3>
#include <GuiStatusBar.au3>
#include <Color.au3>
#include <Date.au3>
#include <GuiListView.au3>
#include <StringSize.au3>
#include <ComboConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
;==[Global variables]====
Global $PathOfCSVFile, $ApplicationName, $CellsFile, $ConfigFile, $MainGUI, $Child, $Wcurve = 800, $Left = 50
Global $hStatus, $aParts[3] = [160, 400, 150], $iTimer1, $Color1 = 0x000000, $Color2 = 0x00f0ff
Global $iMemo, $Slider, $SliderGUI, $Slider_val0, $hImage, $hImage_1, $btn_sendemail
Global $C_Line, $C_Station, $C_PointDeMesure, $hAdlibTimer, $iTime, $Line
Global $olMailItem = 0, $olFormatRichText = 3, $olImportanceLow = 0, $olImportanceNormal = 1, $olImportanceHigh = 2, $olByValue = 1, $olFormatHTML = 2, $olFormatPlain = 1
Global $oOApp, $oOMail, $aItemEmail, $aItemEmailBis, $aItemEmailEmplacement, $EmailTo, $Date, $Author = ""
;==[Program]====
_Ini()
_BuildMainGUI()
While GUIGetMsg() <> -3
WEnd
Func _Ini()
If FileExists(@UserProfileDir & "\MonDossier") = 0 Then
DirCreate(@UserProfileDir & "\MonDossier")
_FileCreate(@UserProfileDir & "\MonDossier\Config.ini")
IniWriteSection(@UserProfileDir & "\MonDossier\Config.ini", StringUpper(@UserName), "")
IniWrite(@UserProfileDir & "\MonDossier\Config.ini", StringUpper(@UserName), "PathOfCSVFile", "C:\temp")
EndIf
$PathOfCSVFile = IniRead(@UserProfileDir & "\MonDossier\Config.ini", StringUpper(@UserName), "PathOfCSVFile", "/!\ Fichier Config.ini erroné /!\")
EndFunc;==>_Ini()
Func _BuildMainGUI();Main Graphical User Interface
$MainGUI = GUICreate($ApplicationName, 1200, 730, -1, -1)
$Size = WinGetClientSize($MainGUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$hStatus = _GUICtrlStatusBar_Create($MainGUI)
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hStatus, "wstr", 0, "wstr", 0)
_GUICtrlStatusBar_SetBkColor($hStatus, 0xf2e300)
$hIcons = _WinAPI_LoadShell32Icon(265); 233 -> Icon ATTENTION,
_GUICtrlStatusBar_SetIcon($hStatus, 0, $hIcons)
GUIRegisterMsg($WM_TIMER, "WM_TIMER")
$iTimer1 = _Timer_SetTimer($MainGUI, 1000)
$LV = GUICtrlCreateListView("Mini|Valeur|Maxi|Date|Réference|ID Logique|Texte résultat", $Left, 470, $Wcurve, 70)
$LVitem = GuiCtrlCreateListViewItem("||||||", $LV)
$iMemo = GUICtrlCreateListView(" ", $Left, 550, $Wcurve, 120, $LVS_NOCOLUMNHEADER)
GUICtrlSendMsg($iMemo, $LVM_SETCOLUMNWIDTH, 0,$Wcurve - 10)
GUICtrlSetFont($iMemo, 8, 800, 0, "MS Sans Serif")
;-->Gestion TREND--------------------------
;---->Label
$l_Line = GUICtrlCreateLabel("Ligne:", $Wcurve + 80, 44, 50, 20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$l_Station = GUICtrlCreateLabel("Station:", $Wcurve + 80, 74, 50, 20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$l_PointDeMesure = GUICtrlCreateLabel("Point de mesure:", $Wcurve + 80, 104, 100, 20)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;------>Bouton
$AfficherCourbeTREND = GUICtrlCreateButton("Afficher la courbe TREND", $Wcurve + 180, 180 , 180, 22)
;GUICtrlSetOnEvent(-1, "_MaFonction")
;---->ComboBox
$C_Line = GUICtrlCreateCombo("", $Wcurve + 180, 40, 180, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
$Line = IniReadSection($ConfigFile, "Lines")
$C_Station = GUICtrlCreateCombo("", $Wcurve + 180, 70, 180, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
;GUICtrlSetOnEvent($C_Line, "_LoadCells")
$C_PointDeMesure = GUICtrlCreateCombo("", $Wcurve + 180, 100, 180, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL))
;GUICtrlSetOnEvent($C_PointDeMesure, "_LoadPointDeMesure")
;-->A définir------------------------------
;-->Options--------------------------------
$btn_open = GuiCtrlCreateButton($PathOfCSVFile, $Wcurve + 100, 500, 225, 20)
GUICtrlSetTip(-1, $PathOfCSVFile);"Dossier d'enregistrement des données")
GUICtrlSetOnEvent(-1, "_ChangePathOfCSVFile")
$hImage = _GUIImageList_Create(16, 16, 5, 3, 1)
_GUICtrlButton_SetImageList($btn_open, $hImage)
_GUIImageList_AddIcon($hImage, "Shell32.dll", 4, True)
_GUICtrlCreateGroup("Gestion TREND: ", $Wcurve + 70, 15, 310, 200)
_GUICtrlCreateGroup("A définir: ", $Wcurve + 70, 242, 310, 200)
_GUICtrlCreateGroup("Options: ", $Wcurve + 70, 470, 310, 200)
;*********************************************************************************************************************
_GUICtrlCreateGradient($Color1, $Color2, 0, 0, $Size[0], $Size[1])
_GUICtrlStatusBar_SetText($hStatus, StringUpper(@username) & " on " & @ComputerName, 1)
GUISetState(@SW_SHOW, $MainGUI)
EndFunc;==>_BuildMainGUI()
Func _ChangePathOfCSVFile(); Change the folder path to put the CSV file from ProMaster request
$NewPathOfCSVFile = FileSelectFolder("Choisir le dossier de destination", "C:\temp", 2)
If Not @error Then
IniDelete(@UserProfileDir & "\MonDossier\Config.ini", StringUpper(@UserName), "PathOfCSVFile")
IniWrite(@UserProfileDir & "\MonDossier\Config.ini", StringUpper(@UserName), "PathOfCSVFile", $NewPathOfCSVFile)
Else
Return
EndIf
EndFunc;==>_ChangePathOfCSVFile()
Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
Local $color1R = _ColorGetRed($nStartColor)
Local $color1G = _ColorGetGreen($nStartColor)
Local $color1B = _ColorGetBlue($nStartColor)
Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight
GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
For $i = 0 To $nHeight - $nY
$sColor = "0x" & StringFormat("%02X%02X%02X", $color1R + $nStepR * $i, $color1G + $nStepG * $i, $color1B + $nStepB * $i)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
Next
EndFunc
Func My_GUICtrlListView_AutoSizeColumns($LV, $iMini = 0)
If Not IsHWnd($LV) Then $LV = GUICtrlGetHandle($LV)
Local $hHeader = _GUICtrlListView_GetHeader($LV), $iHeader_Width, $iData_Width
_GUICtrlListView_BeginUpdate($LV)
For $iIndex = 0 To _GUICtrlListView_GetColumnCount($LV) - 1
If _GUICtrlListView_GetColumnWidth($LV, $iIndex) = 0 Then ContinueLoop
_GUICtrlListView_SetColumnWidth($LV, $iIndex, $LVSCW_AUTOSIZE_USEHEADER)
$iHeader_Width = _GUICtrlListView_GetColumnWidth($LV, $iIndex)
If @OSVersion = "WIN_XP" And $iIndex < _GUICtrlListView_GetColumnCount($LV) - 1 Then
If _GUICtrlHeader_GetItemFlags($hHeader, $iIndex) / 2 > 1 Then $iHeader_Width += 30
EndIf
_GUICtrlListView_SetColumnWidth($LV, $iIndex, $LVSCW_AUTOSIZE)
$iData_Width = _GUICtrlListView_GetColumnWidth($LV, $iIndex)
If $iHeader_Width > $iData_Width Then
_GUICtrlListView_SetColumnWidth($LV, $iIndex, $iHeader_Width)
EndIf
If _GUICtrlListView_GetColumnWidth($LV, $iIndex) < $iMini Then
_GUICtrlListView_SetColumnWidth($LV, $iIndex, $iMini)
EndIf
Next
_GUICtrlListView_EndUpdate($LV)
EndFunc ;==>My_GUICtrlListView_AutoSizeColumns
Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $ilParam
Switch _Timer_GetTimerID($iwParam)
Case $iTimer1
_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 _GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth, $iHeight, $bColor = 0xFFFFFF, $bBkColor = -2, $iStyle = 1, $iBorder = 0)
Local $aLabel[6] = [5], $iCStyle
Local $aStringSize = _StringSize($sText)
If $iStyle Then $iCStyle = $SS_SUNKEN
$aLabel[1] = GUICtrlCreateLabel('', $iLeft + 1, $iTop, 9, 2, $iCStyle) ; Top Left Line.
$aLabel[2] = GUICtrlCreateLabel('', $iLeft + $aStringSize[2] + 10, $iTop, $iWidth - $aStringSize[2] - 10, 2, $iCStyle) ; Top Right Line.
$aLabel[3] = GUICtrlCreateLabel('', $iLeft, $iTop + 2, 2, $iHeight - 4, $iCStyle) ; Left Line.
$aLabel[4] = GUICtrlCreateLabel('', $iLeft + $iWidth - 2, $iTop + 2, 2, $iHeight - 4, $iCStyle) ; Right Line.
$aLabel[5] = GUICtrlCreateLabel('', $iLeft + 1, $iTop + $iHeight - 2, $iWidth - 2, 2, $iCStyle) ; Bottom Line.
For $i = 1 To $aLabel[0]
GUICtrlSetBkColor($aLabel[$i], $bColor)
GUICtrlSetBkColor($aLabel[$i], $bColor)
Next
GUICtrlCreateLabel("", $iLeft + 2, $iTop + 2, $iWidth - 4, $iHeight - 4)
GUICtrlSetBkColor(-1, $bBkColor)
GUICtrlCreateLabel($sText, $iLeft + 12, $iTop - 6, $aStringSize[2], 15, $SS_CENTER)
GUICtrlSetBkColor(-1, $bBkColor)
GUICtrlSetColor(-1, $bColor)
If $iBorder Then
GUICtrlCreateLabel("", $iLeft + 10, $iTop - 6, 2, 8, $iCStyle)
GUICtrlSetBkColor(-1, $bColor)
GUICtrlCreateLabel("", $iLeft + $aStringSize[2] + 10, $iTop - 6, 2, 8, $iCStyle)
GUICtrlSetBkColor(-1, $bColor)
GUICtrlCreateLabel("", $iLeft + 10, $iTop - 8, $aStringSize[2] + 2, 2, $iCStyle)
GUICtrlSetBkColor(-1, $bColor)
EndIF
EndFunc ;==>_GUICtrlCreateGroup
Func _Exit()
Exit
EndFunc;==>Exit()
Func MemoWrite($sMessage)
$hiMemo = GUICtrlCreateListViewItem($sMessage, $iMemo)
; $Slider_val0 < 100 Then GUICtrlSetColor(-1, 0xff0000)
;If $Slider_val0 > 100 Then GUICtrlSetColor(-1, 0x00ff00)
EndFunc

