• So für alle die es noch nicht gesehen haben in dem Hilfeteil, falls es noch jemand brauch:
    eine UDF für Buttons (mit GDI+) mit Bildern

    Spoiler anzeigen
    [autoit]


    #include-once
    #include <GDIPlus.au3>
    #include <Misc.au3>

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

    Local $buttons[1][6];image,posx,posy,$width,$height,state
    Local $othimg[1][2];imagefocus,imagebuttondown
    Local $firstused=0
    Local $hwnd=0
    Local $gra,$buffer,$backgra,$winx,$winy
    Local $lastclickedbutton=-1

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

    Local $testmode=False
    If $testmode=True Then
    $gui=GUICreate("")
    GUISetState()
    _ButtonStartup($gui)
    $p1="";Pfad 1 - Normalbild
    $p2="";Pfad 2 - Bild wenn Button Focus hat
    $p3="";Pfad 3 - Bild wenn Button geklickt wurde
    $button=_ButtonCreate($p1,$p2,$p3,100,100,100,100,0)
    _ButtonSetState($button,1)
    while GUIGetMsg()<>-3
    Sleep(10)
    If _GetLastButton()=$button Then
    MsgBox(0,"","")
    EndIf
    WEnd
    _ButtonShutdown()
    EndIf

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

    Func _ButtonStartup($gui)
    _GDIPlus_Startup()
    $hwnd=$gui
    $gra=_GDIPlus_GraphicsCreateFromHWND($hwnd)
    Local $w,$h
    $winx=_WinAPI_GetClientWidth($hwnd)
    $winy=_WinAPI_GetClientHeight($hwnd)
    $buffer=_GDIPlus_BitmapCreateFromGraphics($winx,$winy,$gra)
    $backgra=_GDIPlus_ImageGetGraphicsContext($buffer)
    AdlibRegister("__ButtonsRedraw",10)
    EndFunc

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

    Func _ButtonCreate($bild,$bildfocus,$bildbd,$px,$py,$width=100,$height=20,$state=1) ;1=show,0=hide
    If $state=1 Then
    $state="show"
    Else
    $state="hide"
    EndIf
    If $firstused=0 Then
    $firstused=1
    Local $bound=0
    Else
    Local $bound=UBound($buttons,1)
    ReDim $buttons[$bound+1][6]
    ReDim $othimg[$bound+1][2]
    EndIf
    $buttons[$bound][0]=_GDIPlus_ImageLoadFromFile($bild)
    $othimg[$bound][0]=_GDIPlus_ImageLoadFromFile($bildfocus)
    $othimg[$bound][1]=_GDIPlus_ImageLoadFromFile($bildbd)
    $buttons[$bound][1]=$px
    $buttons[$bound][2]=$py
    $buttons[$bound][3]=$width
    $buttons[$bound][4]=$height
    $buttons[$bound][5]=$state
    Return $bound ;Button-ID für _ButtonSetState, kleinstes: 0
    EndFunc

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

    Func _GetLastButton()
    Local $tmp=$lastclickedbutton
    $lastclickedbutton=-1
    Return $tmp
    EndFunc

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

    Func _ButtonSetState($buttonid,$state=1)
    If $state=1 Then
    $state="show"
    Else
    $state="hide"
    EndIf
    $buttons[$buttonid][5]=$state
    EndFunc

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

    Func _ButtonShutdown()
    AdlibUnRegister("__ButtonsRedraw")
    For $x=0 To UBound($buttons,1)-1
    _GDIPlus_ImageDispose($buttons[$x][0])
    _GDIPlus_ImageDispose($othimg[$x][0])
    _GDIPlus_ImageDispose($othimg[$x][1])
    Next
    _GDIPlus_GraphicsDispose($backgra)
    _GDIPlus_BitmapDispose($buffer)
    _GDIPlus_GraphicsDispose($gra)
    _GDIPlus_Shutdown()
    EndFunc

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

    Func __ButtonsRedraw()
    Local $nowimage
    Local $pos=_WinAPI_GetMousePos(True,$hwnd)
    Local $erg
    For $x=0 To UBound($buttons,1)-1
    If $buttons[$x][5]="show" Then
    $rect=__NewRect($buttons[$x][1],$buttons[$x][2],$buttons[$x][3],$buttons[$x][4])
    If _WinAPI_PtInRect($rect,$pos) Then
    $nowimage=$othimg[$x][0]
    If _IsPressed("1") Then
    $nowimage=$othimg[$x][1]
    $lastclickedbutton=$x
    EndIf
    Else
    $nowimage=$buttons[$x][0]
    EndIf
    _GDIPlus_GraphicsDrawImageRect($backgra,$nowimage,$buttons[$x][1],$buttons[$x][2],$buttons[$x][3],$buttons[$x][4])
    EndIf
    Next
    _GDIPlus_GraphicsDrawImageRect($gra,$Buffer,0,0,$winx,$winy)
    EndFunc

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

    Func __NewRect($x=0,$y=0,$w=0,$h=0)
    Local $struct=DllStructCreate("uint Left;uint Top;uint Right;uint Bottom");$tagRECT
    DllStructSetData($struct,"Left",$x)
    DllStructSetData($struct,"Top",$y)
    DllStructSetData($struct,"Right",$x+$w)
    DllStructSetData($struct,"Bottom",$y+$h)
    Return $struct
    EndFunc

    [/autoit]

    Nichts Besonderes aber vielleicht brauchen es noch ein paar Leute

    Einmal editiert, zuletzt von TheShadowAE (27. Mai 2010 um 15:54)

  • Kann mich Ubuntu nur anschließen ^^

    Spoiler anzeigen

    Grundkenntnisse in: C++, JavaScript
    Sehr gute Kenntnisse: PHP, JAVA, C und näturlich AutoIt


    Klaviatur, Anhang UDF, GDI+ Mühle

    Zitat

    "Wenn einen um 20h der Pizzadienst anruft und fragt, ob man's nur vergessen hat und ob man das gleiche
    möchte wie immer -- dann sollte man sein Bestellverhalten evtl überdenken"