1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Rufio

Beiträge von Rufio

  • GUICtrlCreateButton (funktioniert) bzw. GUICtrlCreatePic (funktioniert nicht) aus Ini-Section erstellen

    • Rufio
    • 5. August 2019 um 12:19

    Die Bilder sind teilweise 24- und 32-bittig, aber das scheint nicht das Problem zu sein...

  • GUICtrlCreateButton (funktioniert) bzw. GUICtrlCreatePic (funktioniert nicht) aus Ini-Section erstellen

    • Rufio
    • 5. August 2019 um 12:18

    Danke für die schnelle Antwort :thumbup:

    Code
    #include <GUIConstants.au3>
    Opt ("GUIOnEventMode", 1)
    Local $DPIAware = DllCall ("user32.dll", "bool", "SetProcessDPIAware")
    DllClose ($DPIAware)
    
    $ConfigFile = @ScriptDir & "\config.ini"
    $ButtonsFile = @ScriptDir & "\buttons.cfg"
    $GUI_Name = IniRead ($ConfigFile, "GUI", "Name", 0)
    $GUI_Breite = IniRead ($ConfigFile, "GUI", "Breite", 0)
    $GUI_Hoehe = IniRead ($ConfigFile, "GUI", "Hoehe", 0)
    $GUI_PositionX = IniRead ($ConfigFile, "GUI", "PositionX", 0)
    $GUI_PositionY = IniRead ($ConfigFile, "GUI", "PositionY", 0)
    $GUI_Hintergrundbild = IniRead ($ConfigFile, "GUI", "Hintergrundbild", 0)
    
    $GUI = GUICreate ($GUI_Name, @DesktopWidth, @DesktopHeight, $GUI_PositionX, $GUI_PositionY, $WS_POPUP)
    GUISetOnEvent ($GUI_EVENT_CLOSE, "_Exit")
    GUICtrlCreatePic ($GUI_Hintergrundbild, 0, 0, $GUI_Breite, $GUI_Hoehe)
    
    $Sections = IniReadSectionNames ($ButtonsFile)
    If @error Then Exit
    
    Dim $Button[$Sections[0]],$Picture[$Sections[0]]
    For $i = 1 To $Sections[0]-1
        $Position = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Position", ""), ",")
        $Size = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Size", ""), ",")
        $Image = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Image", ""), ",")
        ;$Button[$i-1] = GUICtrlCreateButton ($Sections[$i], $Position[1], $Position[2], $Size[1], $Size[2], $BS_BITMAP)
        ;GUICtrlSetImage (-1, @ScriptDir & "\gfx\" & $Image[1])
        $Button[$i-1] = GUICtrlCreatePic (@ScriptDir & "\gfx\" & $Image[1], $Position[1], $Position[2], $Size[1], $Size[2])
        ConsoleWrite (GUICtrlRead ($Button[$i-1]) & @CRLF)
    Next
    
    GUISetState ()
    
    While 1
        Sleep (1000)
    WEnd
    
    Func _Exit()
       Exit
    EndFunc
    Alles anzeigen

    Config.ini:

    [GUI]

    Name = Dashboard

    Breite = 1920

    Hoehe = 1080

    PositionX = 0

    PositionY = 0

    Hintergrundbild = bg.jpg

    Und Buttons.cfg im ini-format:

    [Kodi]

    Name = Kodi

    Size = 192,192

    Position = 32,32

    Image = kodi.bmp,kodi_h.bmp

    [Steam]

    Name = Steam

    Size = 192,192

    Position = 224,32

    Image = steam.bmp,steam_h.bmp

    [Amiga]

    Name = Amiga

    Size = 192,192

    Position = 416,32

    Image = amiga.bmp,amiga_h.bmp

    [ScummVM]

    Name = ScummVM

    Size = 192,192

    Position = 608,32

    Image = scummvm.bmp,scummvm_h.bmp

    [SNES]

    Name = Super Nintendo

    Size = 192,192

    Position = 800,32

    Image = snes.bmp,snes_h.bmp

    [N64]

    Name = N64

    Size = 192,192

    Position = 992,32

    Image = n64.bmp,n64_h.bmp

    [GameCube]

    Name = Nintendo GameCube

    Size = 192,192

    Position = 1184,32

    Image = ngc.bmp,ngc_h.bmp

    [Wii]

    Name = Nintendo Wii

    Size = 192,192

    Position = 1376,32

    Image = nwii.bmp,nwii_h.bmp

    kodi.bmp

    amiga.bmp

    n64.bmp

    ngc.bmp

    scummvm.bmp

    snes.bmp

    steam.bmp

    wii.bmp

  • GUICtrlCreateButton (funktioniert) bzw. GUICtrlCreatePic (funktioniert nicht) aus Ini-Section erstellen

    • Rufio
    • 3. August 2019 um 16:10

    Hallo zusammen, das ist mein erstes Thema hier im Forum.

    Ich versuche normalerweise selbst eine Lösung zu finden, jedoch hänge ich an diesem Problem jetzt schon zu lange.

    Es geht darum, per For-Loop Einträge aus einer INI-Datei zu lesen und die Sectionnames als Bezeichnung für Buttons zu nutzen.

    Hier mal das Script:

    Code
    $Sections = IniReadSectionNames ($ButtonsFile)
    If @error Then Exit
    
    Dim $Button[$Sections[0]]
    For $i = 1 To $Sections[0]
        $Position = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Position", ""), ",")
        $Size = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Size", ""), ",")
        $Image = StringSplit (IniRead ($ButtonsFile, $Sections[$i], "Image", ""), ",")
        $Button[$i-1] = GUICtrlCreateButton ($Sections[$i], $Position[1], $Position[2], $Size[1], $Size[2], $BS_BITMAP)
        GUICtrlSetImage (-1, @ScriptDir & "\gfx\" & $Image[1])
    Next
    Alles anzeigen

    Die Buttons werden auch alle erstellt, jedoch werden nur 6 der insgesamt 8 Bilder auf die Knöpfe gelegt.

    Ich würde eigentlich auch lieber GUICtrlCreatePic anstelle von GUICtrlCreateButton verwenden, da ich den gepunkteten Focus nicht wegbekomme, aber dann werden mir gar nicht erst alle Buttons bzw. Pics angezeigt, sondern auch wieder nur 6 von 8...

    Code
    Button[$i-1] = GUICtrlCreatePic (@ScriptDir & "\gfx\" & $Image[1], $Position[1], $Position[2], $Size[1], $Size[2])

    Es hat sicherlich was mit Arrays / UBound oder sonstwas zu tun, allerdings habe ich mich damit bisher so in den Wahnsinn getrieben, dass ich jetzt wirklich Hilfe dazu brauche :/

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™