Ich habe in die Access DB jetzt noch ein Spalte für die Label ID bzw. Icon ID aufgenommen und schreibe dann die Werte beim erstellen in diese Spalte.
$aLabels[$i][4]
$aIcons[$i][4]
Das anklicken der Icon und Label funktioniert jetzt auch. Hier war der Fehler, dass in der DB nicht alle Felder mit Icon Werten gefüllt waren, somit 0 Werte drin standen.
Spoiler anzeigen
AutoIt
#AutoIt3Wrapper_UseX64=y
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <D:\Scripte\MS_AccessCom\Access UDF\Access_UDF.au3>
#include <D:\Scripte\ArrayMultiColSort\ArrayMultiColSort.au3>
;--------- MSAccess DB ------------
$dbname = @ScriptDir & "\bin\db\Helpdesk.accdb"
$tblname001 = "Systeme"
Local $Connection = _Start_Connection($dbname & ";")
Local $Array_Systeme = _Get_Records("SELECT * FROM " & $tblname001 & ";")
_Close_Connection()
;----------------------------------
;----- Sort Array nach Col3 -------
;sortiere nach Col3
Global $aSortData[][] = [ _
[3, 0]]
; Sort and display array
_ArrayMultiColSort($Array_Systeme, $aSortData)
;_ArrayDisplay($Array_Systeme)
;----------------------------------
Local $aIcons = $Array_Systeme
Local $aLabels = $Array_Systeme
$hGUI = GUICreate("GUI Test", 800, 720)
; Create the buttons and add their ControlIDs to the array
For $i = 0 To UBound($Array_Systeme) - 1
$aIcons[$i][4] = GUICtrlCreateIcon(@ScriptDir & "\bin\icons\" & $Array_Systeme[$i][2],"", 11 + (60 * $i), 70, 40, 40)
GUICtrlSetTip($aIcons[$i][4], $Array_Systeme[$i][1])
;$aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (59 * $i), 115, 60, 30)
$aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 10 + (60 * $i), 115, 60, 30,0x01) ;center Txt
GUICtrlSetTip($aLabels[$i][4], $Array_Systeme[$i][1])
Next
;_ArrayDisplay($aIcons)
;_ArrayDisplay($aLabels)
GUISetState()
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
Case Else
For $x = 0 To UBound($Array_Systeme) - 1
If $iMsg = $aLabels[$x][4] or $iMsg = $aIcons[$x][4] Then
; If so then display the data
MsgBox(0, "Label clicked", $aLabels[$x][1])
; No point in looking further
ExitLoop
EndIf
Next
EndSwitch
WEnd
Alles anzeigen
Hier mal mit Fixer Ausrichtung der Labels
AutoIt
#AutoIt3Wrapper_UseX64=y
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <D:\Scripte\MS_AccessCom\Access UDF\Access_UDF.au3>
#include <D:\Scripte\ArrayMultiColSort\ArrayMultiColSort.au3>
;--------- MSAccess DB ------------
$dbname = @ScriptDir & "\bin\db\Helpdesk.accdb"
$tblname001 = "Systeme"
Local $Connection = _Start_Connection($dbname & ";")
Local $Array_Systeme = _Get_Records("SELECT * FROM " & $tblname001 & ";")
_Close_Connection()
;----------------------------------
;----- Sort Array nach Col3 -------
;sortiere nach Col3
Global $aSortData[][] = [ _
[3, 0]]
; Sort and display array
_ArrayMultiColSort($Array_Systeme, $aSortData)
;_ArrayDisplay($Array_Systeme)
;----------------------------------
Local $aIcons = $Array_Systeme
Local $aLabels = $Array_Systeme
$hGUI = GUICreate("GUI Test", 800, 720)
; Create the buttons and add their ControlIDs to the array
For $i = 0 To UBound($Array_Systeme) - 1
$aIcons[$i][4] = GUICtrlCreateIcon(@ScriptDir & "\bin\icons\" & $Array_Systeme[$i][2],"", 20 + (60 * $i), 70, 40, 40)
GUICtrlSetTip($aIcons[$i][4], $Array_Systeme[$i][1])
;$aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 25 + (60 * $i -4), 115, 60, 30)
IF $i = 0 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 30 + (60 * $i), 115, 60, 30)
IF $i = 1 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 30 + (60 * $i), 115, 60, 30)
IF $i = 2 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 25 + (60 * $i), 115, 60, 30)
IF $i = 3 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 26 + (60 * $i), 115, 60, 30)
IF $i = 4 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (60 * $i), 115, 60, 30)
IF $i = 5 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (60 * $i), 115, 60, 30)
IF $i = 6 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 22 + (60 * $i), 115, 60, 30)
IF $i = 7 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 24 + (60 * $i), 115, 60, 30)
IF $i = 8 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 20 + (60 * $i), 115, 60, 30)
IF $i = 9 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 22 + (60 * $i), 115, 60, 30)
IF $i = 10 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 30 + (60 * $i), 115, 60, 30)
IF $i = 11 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 25 + (60 * $i), 115, 60, 30)
IF $i = 12 Then $aLabels[$i][4] = GUICtrlCreateLabel($Array_Systeme[$i][1], 17 + (60 * $i), 115, 60, 30)
GUICtrlSetTip($aLabels[$i][4], $Array_Systeme[$i][1])
Next
_ArrayDisplay($aIcons)
_ArrayDisplay($aLabels)
GUISetState()
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
Exit
; Was the ControlID a button?
Case Else
For $x = 0 To UBound($Array_Systeme) - 1
If $iMsg = $aLabels[$x][4] or $iMsg = $aIcons[$x][4] Then
; If so then display the data
MsgBox(0, "Label clicked", $aLabels[$x][1])
; No point in looking further
ExitLoop
EndIf
Next
EndSwitch
WEnd
Alles anzeigen
Gruß gmmg