Schaltflächen mit Icons

  • Kannst du mit GUICtrlSetImage machen.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 625, 443, 192, 124)
    $Button1 = GUICtrlCreateButton("Button1", 80, 56, 80, 50, $WS_GROUP)
    GUICtrlSetImage($Button1, @SystemDir & "\shell32.dll", -21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Super danke!

    Jetzt suche ich noch eine Möglichkeit die .ico in mein Programm einzubinden. Aber wenn möglich nicht über die "FileInstall"-variante sondern fix integriert.

    Und gibt es eine Möglichkeit Einzustellen das die Schaltflächen dann nicht Zweidimensional werden?

    Einmal editiert, zuletzt von DerSchatten (5. August 2011 um 13:23)

  • Hallo DerSchatten,

    eine Alternative zu FileInstall ist ;Fremddateien "includen" (ohne FileInstall). Für Bilder auf Buttons benutze ich eine ImageList, dies sieht dann so aus:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #include <GUIConstantsEx.au3>
    #include <GuiButton.au3>
    #include <GuiImageList.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _Main()

    [/autoit] [autoit][/autoit] [autoit]

    Func _Main()
    Local $sBMPNormal = @ScriptDIR & "\Icons\dsFirst_NORMAL.BMP"
    Local $sBMPHot = @ScriptDir & "\Icons\dsFirst_mouseover.bmp"
    Local $sBMPPress = @ScriptDir & "\Icons\dsFirst_mousedown.bmp"
    Local $sBMPImage = @WindowsDir & "\pchealth\helpctr\System\blurbs\watermark_300x.bmp"
    Local $btn1, $btn2, $btn3, $btn4, $msg
    Local $hImagebtn1, $hImagebtn2, $hImagebtn3 ,$hImagebtn4

    [/autoit] [autoit][/autoit] [autoit]

    ;Caveat: Minimum Operating Systems: Windows XP.

    [/autoit] [autoit][/autoit] [autoit]

    ;Image list with multiple images will only show the images
    ;other than the 1st image when Themes are used.

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("Button Imagelists - Minimum OS: Windows XP",400,300)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 400, 300)
    GUICtrlSetState(-1, $GUI_DISABLE)

    [/autoit] [autoit][/autoit] [autoit]

    ;multi state image Bitmap
    $btn1 = GUICtrlCreateButton("This Way", 30, 30, 90, 32)
    GUICtrlSetTip(-1, "Multi state bitmap imagelist")
    $hImagebtn1 = _GUIImageList_Create(24, 24, 3, 3)
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);1 - Normal
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPHot) ;2 - Hot
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPPress) ;3 - Pressed
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPPress);4 - Disabled
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);5 - Defaulted
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);6 - Stylus Hot (tablet computers only)
    _GUICtrlButton_SetImageList($btn1, $hImagebtn1)

    [/autoit] [autoit][/autoit] [autoit]

    ;single state image Bitmap
    $btn2 = GUICtrlCreateButton("This Way", 30, 70, 90, 32)
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetTip(-1, "Single bitmap imagelist")
    $hImagebtn2 = _GUIImageList_Create(24, 24, 5, 3)
    _GUIImageList_AddBitmap($hImagebtn2, $sBMPNormal);1 - Normal
    _GUICtrlButton_SetImageList($btn2, $hImagebtn2)

    [/autoit] [autoit][/autoit] [autoit]

    ;single state image Icon
    $btn3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40)
    GUICtrlSetTip(-1, "Single icon imagelist")
    $hImagebtn3 = _GUIImageList_Create(32, 32, 5, 3)
    _GUIImageList_AddIcon($hImagebtn3, "msrating.dll", 10, True)
    _GUICtrlButton_SetImageList($btn3, $hImagebtn3)

    [/autoit] [autoit][/autoit] [autoit]

    ;single state image Bitmap with overlayed text
    $btn4 = GUICtrlCreateButton("Help", 30, 160, 90, 90)
    GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text")
    GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS")
    $hImagebtn4 = _GUIImageList_Create(80, 80, 5, 3)
    _GUIImageList_AddBitmap($hImagebtn4, $sBMPImage)
    _GUICtrlButton_SetImageList($btn4, $hImagebtn4, 4)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $btn1
    Case $btn2
    GUICtrlSetState($btn1, $GUI_DISABLE)
    Case $btn3
    GUICtrlSetState($btn1, $GUI_ENABLE)
    Case $btn4
    EndSwitch
    WEnd
    EndFunc ;==>_Main

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    mfg autoBert

  • Zitat

    Eine Möglichkeit Dateien ohne zwischensoeichern direkt aus der exe auszulesen gibt es wohl nicht?


    Doch. Bei Bildern sollte das mit ein wenig WinAPI und GDI+ Zauberei kein Problem sein. Quäl mal die Forensuche, ich bin mir ziemlich sicher, dass es sowas hier schon mal gab.