ATR Posted June 9, 2016 Posted June 9, 2016 (edited) Hi all, I have a problem with my array ! The first colum is changed when I create my checkbox. How can I conserve values of the column ? expandcollapse popupGlobal $Array_Programmes[4][3] = [ _ ["Malwarebytes Anti-Malware", "Malwarebytes.exe", @WorkingDir & "\malwarebytes.png"], _ ["AdwCleaner", "AdwCleaner.exe", @WorkingDir & "\adwcleaner.png"], _ ["JRT", "JRT.exe", @WorkingDir & "\JRT.png"], _ ["ZHPCleaner", "ZHPCleaner.exe", @WorkingDir & "\avatar-Nico-100x100.png"]] Global $Gui = GUICreate("", 250, 250) $Specs = GUICtrlCreateButton("View specs", 50, 220, 100, 26) ; Automatique OK _GUICtrlPic_Create(@WorkingDir & "\select_all.png", 10, 5, 30, 30) $Select_all = GUICtrlCreateCheckbox("Sélectionner tout", 50, 10, -1, 30) $Left_Checkbox = 50 $Left_Image = 10 $Top = 50 For $i = 0 To UBound($Array_Programmes) - 1 _GUICtrlPic_Create($Array_Programmes[$i][2], $Left_Image, $Top, 30, 30) $Array_Programmes[$i][0] = GUICtrlCreateCheckbox($Array_Programmes[$i][0], 50, 50, 120) ;Here the array change the first column $Top += 40 Next GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Specs _ArrayDisplay($Array_Programmes) ; The first column of the array is changed For $i = 0 To UBound($Array_Programmes) - 1 If BitAND(GUICtrlRead($Array_Programmes[$i][0]), $GUI_CHECKED) = $GUI_CHECKED Then $Name = StringRegExpReplace($Array_Programmes[$i][0], "[^A-Za-z0-9]", "_") ConsoleWrite("$Nom_Fonction :" & $Name & @LF) EndIf Next EndSwitch WEnd GUIDelete($Gui) Func _GUICtrlPic_Create($sFilename, $iLeft, $iTop, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = -1) _GDIPlus_Startup() Local $idPic = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sFilename) If $iWidth = -1 Then $iWidth = _GDIPlus_ImageGetWidth($hBitmap) If $iHeight = -1 Then $iHeight = _GDIPlus_ImageGetHeight($hBitmap) Local $hBitmap_Resized = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized) _GDIPlus_GraphicsSetInterpolationMode($hBMP_Ctxt, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, $iWidth, $iHeight) Local $hHBitmap = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap_Resized) Local $hPrevImage = GUICtrlSendMsg($idPic, $STM_SETIMAGE, 0, $hHBitmap) ; $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject($hPrevImage); Delete Prev image if any _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Resized) _GDIPlus_GraphicsDispose($hBMP_Ctxt) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_Shutdown() Return $idPic EndFunc ;==>_GUICtrlPic_Create Thank you Edited June 9, 2016 by ATR
jguinch Posted June 9, 2016 Posted June 9, 2016 (edited) Declare your $Array_Programmes with 4 columns, and store the CheckBox ID in the 4th column : Global $Array_Programmes[4][4] = [ _ ["Malwarebytes Anti-Malware", "Malwarebytes.exe", @WorkingDir & "\malwarebytes.png"], _ ["AdwCleaner", "AdwCleaner.exe", @WorkingDir & "\adwcleaner.png"], _ ["JRT", "JRT.exe", @WorkingDir & "\JRT.png"], _ ["ZHPCleaner", "ZHPCleaner.exe", @WorkingDir & "\avatar-Nico-100x100.png"]] ; [...] $Array_Programmes[$i][3] = GUICtrlCreateCheckbox($Array_Programmes[$i][0], 50, $top, 120) ; [...] Edited June 9, 2016 by jguinch Reveal hidden contents Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
ATR Posted June 9, 2016 Author Posted June 9, 2016 On 6/9/2016 at 9:14 PM, jguinch said: Declare your $Array_Programmes with 4 columns, and store the CheckBox ID in the 4th column : Global $Array_Programmes[4][4] = [ _ ["Malwarebytes Anti-Malware", "Malwarebytes.exe", @WorkingDir & "\malwarebytes.png"], _ ["AdwCleaner", "AdwCleaner.exe", @WorkingDir & "\adwcleaner.png"], _ ["JRT", "JRT.exe", @WorkingDir & "\JRT.png"], _ ["ZHPCleaner", "ZHPCleaner.exe", @WorkingDir & "\avatar-Nico-100x100.png"]] ; [...] $Array_Programmes[$i][3] = GUICtrlCreateCheckbox($Array_Programmes[$i][0], 50, $top, 120) ; [...] Expand I'm really stupid not to have thought! Thank you!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now