Fliegende Schrift über Bild mit GDI

  • huhu...

    Also da ich leider nur sehr wenig Ahnung in Sachen GDI habe, ich aber etwas brauche was meiner Meinung nach nur mit der GDi geht ... bräuchte ich mal etwas Hilfe..
    Ich habe bei mir in der Firma eine Informationssoftware entwickelt, die kurz vor der fertigstellung ist.
    Jetzt benötige ich aber damit beim starten des Servers es etwas schöner aussieht und die Wartezeit etwas verschleiert wird ein Art Intro.

    Eigentlich funktioniert es auch schon so wie ich es will... aber ich denke mal das es so sehr Umständlich gestaltet ist.
    Hier erst mal der Quellcode.. :S

    Spoiler anzeigen
    [autoit]


    #include-once
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <WinAPI.au3>
    #include <GDIPlus.au3>
    #include <StaticConstants.au3>

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

    $Gui_width = 430
    $Gui_height = 236
    $Gui_Pos_X = -1
    $Gui_Pos_Y = -1

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

    $hGui = GUICreate('', $Gui_width, $Gui_height ,$Gui_Pos_X,$Gui_Pos_y,$WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))

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

    $hpic_bg = GUICtrlCreatePic('',0,0,430,236)
    _SetImagefromResource($hpic_bg, "hg", "data.dll",2)

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

    $hLabel_Version = GUICtrlCreateLabel( 'v. 2.0.1.64',$Gui_width-105,3,100,10, $SS_RIGHT)
    GUICtrlSetBkColor ( -1,$GUI_BKCOLOR_TRANSPARENT )
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")
    GUICtrlSetColor (-1, 0xB0C4DE )
    $hLabel_Footer = GUICtrlCreateLabel( 'Lizenz: ---'&@CRLF& _
    'Beta Version'&@CRLF& _
    'C .Schiffer 2010',$Gui_width-125,$Gui_height-42,120,40,$SS_RIGHT)
    GUICtrlSetBkColor ( -1,$GUI_BKCOLOR_TRANSPARENT )
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")
    GUICtrlSetColor (-1, 0x000000 )

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

    _WinFadeIn($hGui)

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

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
    Sleep ( 300 )
    _StringFadeIn('Starte',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('Starte.',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte..',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte...',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte....',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('Starte....',50,190)

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

    _StringFadeIn('prüfe Daten',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten.',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten..',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten...',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten....',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('prüfe Daten....',50,190)

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

    _StringFadeIn('starte Server',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('starte Server (15%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (30%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (60%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (85%)',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('starte Server (100%)',50,190)
    Sleep (300)
    _WinFadeOut($hGui)

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

    ;-------------------------------------------------------------------------------------------------
    ; Verändern
    ;-------------------------------------------------------------------------------------------------
    Func _StringSetNewText($sString,$Pos_X,$Pos_Y)
    _SetImagefromResource($hpic_bg, "hg", "data.dll",2)
    GUICtrlSetState ( $hLabel_Version,$GUI_SHOW )
    GUICtrlSetState ( $hLabel_Footer,$GUI_SHOW )
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex(255, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 13, 1)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    $tLayout = _GDIPlus_RectFCreate( $Pos_X, $Pos_Y, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; String Einblenden
    ;-------------------------------------------------------------------------------------------------
    Func _StringFadeIn($sString,$Pos_X,$Pos_Y,$Step = 25 ,$Time = 20 )
    $timerinit = TimerInit()
    For $i = 0 To 255 Step $Step
    Do
    Sleep (1)
    Until TimerDiff($timerinit) > $Time
    $timerinit = TimerInit()
    _SetImagefromResource($hpic_bg, "hg", "data.dll",2)
    GUICtrlSetState ( $hLabel_Version,$GUI_SHOW )
    GUICtrlSetState ( $hLabel_Footer,$GUI_SHOW )
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex($i, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 13-((255/30)-($i/30)), 1)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    If (255/8)-($i/8) < 2 Then
    $Pos_Y_Wert = $Pos_Y+0
    Else
    $Pos_Y_Wert = $Pos_Y+(255/8)-($i/8)
    EndIf
    $tLayout = _GDIPlus_RectFCreate( $Pos_X, $Pos_Y_Wert, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    Next
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; String Ausblenden
    ;-------------------------------------------------------------------------------------------------
    Func _StringFadeOut($sString,$Pos_X,$Pos_Y,$Step = 25 ,$Time = 15)
    $timerinit = TimerInit()
    For $i = 255 To 0 Step -$Step
    If $i < 11 Then $i = 0
    Do
    Sleep (1)
    Until TimerDiff($timerinit) > $Time
    $timerinit = TimerInit()
    _SetImagefromResource($hpic_bg, "hg", "data.dll",2)
    GUICtrlSetState ( $hLabel_Version,$GUI_SHOW )
    GUICtrlSetState ( $hLabel_Footer,$GUI_SHOW )
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex($i, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 13-((255/30)-($i/30)), 1)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    $tLayout = _GDIPlus_RectFCreate($Pos_X, $Pos_Y, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    Next
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Gui Einblenden
    ;-------------------------------------------------------------------------------------------------
    Func _WinFadeIn($hGui,$timertime = 20 ,$blendzize = 1.25 )
    WinSetTrans($hGui, "",0)
    GUISetState ( @SW_SHOW, $hGui)
    $i = 1
    $timerinit = TimerInit()
    Do
    If TimerDiff($timerinit) > $timertime Then
    $i = $i*$blendzize
    If $i > 255 Then ExitLoop
    WinSetTrans($hGui, "",$i)
    $timerinit = TimerInit()
    EndIf
    Until $i > 255
    WinSetTrans($hGui, "",255)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Gui Ausblenden
    ;-------------------------------------------------------------------------------------------------
    Func _WinFadeOut($hGui,$timertime = 20 ,$blendzize = 0.75 )
    WinSetTrans($hGui, "",255)
    $i = 255
    $timerinit = TimerInit()
    Do
    If TimerDiff($timerinit) > $timertime Then
    $i = $i*$blendzize
    If $i < 5 Then ExitLoop
    WinSetTrans($hGui, "",$i)
    $timerinit = TimerInit()
    EndIf
    Until $i < 5
    WinSetTrans($hGui, "",0)
    GUISetState ( @SW_HIDE, $hGui)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Image aus dll
    ;-------------------------------------------------------------------------------------------------
    Func _SetImagefromResource($CtrlID, $Resname, $Resfile = -1, $ResType = 10)
    Local Const $IMAGE_BITMAP = 0
    Local Const $STM_SETIMAGE = 0x0172
    Local $hmod, $hwnd, $InfoBlock, $ResSize, $Mem, $pMem, $dll, $dll2, $hData, $pData, $pStream, $ret, $hBitmap, $pBitmap
    $hmod = _WinAPI_LoadLibrary($Resfile)
    If $ResType = 2 Then
    $hBitmap = _WinAPI_LoadImage($hmod, $Resname, $IMAGE_BITMAP, 0, 0, 0)
    If @error Then Return SetError(1, 0, 0)
    $hwnd = GUICtrlGetHandle($CtrlID)
    If $hwnd = 0 Then Return SetError(2, 0, 0)
    DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hwnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    If @error Then Return SetError(3, 0, 0)
    EndIf
    EndFunc

    [/autoit]


    Damit man das Bild sieht müsst ihr die dll im Verzeichnis haben, die Angehangen ist.

    In meiner jetztigen Version Zeichne ich immer in eine GDI Grafik den Text und überschreibe es dann wieder mit dem Hintergrundbild..
    das ist aber etwas unsinnig und flackert etwas...

    Wäre froh über einen bessere Lösung...
    Danke schonmal

    MFG chris :D

  • Ich habe mal deinen Code etwas verändert, so dass jetzt mit einem Backbuffer gearbeitet wird, um das Flackern zu verhindern.

    Spoiler anzeigen
    [autoit]


    #include-once
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <WinAPI.au3>
    #include <GDIPlus.au3>
    #include <StaticConstants.au3>

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

    $Gui_width = 430
    $Gui_height = 236
    $Gui_Pos_X = -1
    $Gui_Pos_Y = -1

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

    $hGui = GUICreate('', $Gui_width, $Gui_height ,$Gui_Pos_X,$Gui_Pos_y,$WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
    WinSetTrans($hGui, "",0)
    GUISetState()
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Gui_width, $Gui_height, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    $hImage = _SetImagefromResource(0, "hg", "data.dll",2)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
    $hBrush_Label = _GDIPlus_BrushCreateSolid (0xFFB0C4DE)
    $hBrush_Label2 = _GDIPlus_BrushCreateSolid (0xFF000000)
    $hFormat_Label = _GDIPlus_StringFormatCreate ()
    $hFamily_Label = _GDIPlus_FontFamilyCreate ("Arial")
    $hFont_Label = _GDIPlus_FontCreate ($hFamily_Label, 8, 2)
    $tLayout_Label = _GDIPlus_RectFCreate ($Gui_width - 60, 3, 100, 20)
    $tLayout_Label2 = _GDIPlus_RectFCreate ($Gui_width - 100, $Gui_height - 50, 100, 80)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic, "v. 2.0.1.64", $hFont_Label, $tLayout_Label, $hFormat_Label, $hBrush_Label)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic, 'Lizenz: ---' & @CRLF & _
    'Beta Version'&@CRLF& _
    'C .Schiffer 2010', $hFont_Label, $tLayout_Label2, $hFormat_Label, $hBrush_Label2)
    _WinFadeIn($hGui)

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

    Sleep ( 300 )
    _StringFadeIn('Starte',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('Starte.',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte..',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte...',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte....',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('Starte....',50,190)

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

    _StringFadeIn('prüfe Daten',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten.',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten..',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten...',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten....',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('prüfe Daten....',50,190)

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

    _StringFadeIn('starte Server',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('starte Server (15%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (30%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (60%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (85%)',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('starte Server (100%)',50,190)
    Sleep (300)
    _WinFadeOut($hGui)

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

    _GDIPlus_FontDispose($hFont_Label)
    _GDIPlus_FontFamilyDispose($hFamily_Label)
    _GDIPlus_StringFormatDispose($hFormat_Label)
    _GDIPlus_BrushDispose($hBrush_Label)
    _GDIPlus_BrushDispose($hBrush_Label2)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown ()
    Exit
    ;-------------------------------------------------------------------------------------------------
    ; Verändern
    ;-------------------------------------------------------------------------------------------------
    Func _StringSetNewText($sString,$Pos_X,$Pos_Y)
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, 0, 0)
    Label()
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex(255, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 13, 1)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    $tLayout = _GDIPlus_RectFCreate( $Pos_X, $Pos_Y, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $Gui_width, $Gui_height)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; String Einblenden
    ;-------------------------------------------------------------------------------------------------
    Func _StringFadeIn($sString,$Pos_X,$Pos_Y,$Step = 25 ,$Time = 20 )
    $timerinit = TimerInit()
    For $i = 0 To 255 Step $Step
    Do
    Sleep (1)
    Until TimerDiff($timerinit) > $Time
    $timerinit = TimerInit()
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, 0, 0)
    Label()
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex($i, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 13-((255/30)-($i/30)), 1)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    If (255/8)-($i/8) < 2 Then
    $Pos_Y_Wert = $Pos_Y+0
    Else
    $Pos_Y_Wert = $Pos_Y+(255/8)-($i/8)
    EndIf
    $tLayout = _GDIPlus_RectFCreate( $Pos_X, $Pos_Y_Wert, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $Gui_width, $Gui_height)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    Next
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; String Ausblenden
    ;-------------------------------------------------------------------------------------------------
    Func _StringFadeOut($sString,$Pos_X,$Pos_Y,$Step = 25 ,$Time = 15)
    $timerinit = TimerInit()
    For $i = 255 To 0 Step -$Step
    If $i < 11 Then $i = 0
    Do
    Sleep (1)
    Until TimerDiff($timerinit) > $Time
    $timerinit = TimerInit()
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, 0, 0)
    Label()
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex($i, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 13-((255/30)-($i/30)), 1)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    $tLayout = _GDIPlus_RectFCreate($Pos_X, $Pos_Y, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $Gui_width, $Gui_height)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    Next
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Gui Einblenden
    ;-------------------------------------------------------------------------------------------------
    Func _WinFadeIn($hGui,$timertime = 20 ,$blendzize = 1.25 )
    WinSetTrans($hGui, "",0)
    GUISetState ( @SW_SHOW, $hGui)
    $i = 1
    $timerinit = TimerInit()
    Do
    If TimerDiff($timerinit) > $timertime Then
    $i = $i*$blendzize
    If $i > 255 Then ExitLoop
    WinSetTrans($hGui, "",$i)
    $timerinit = TimerInit()
    EndIf
    Until $i > 255
    WinSetTrans($hGui, "",255)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Gui Ausblenden
    ;-------------------------------------------------------------------------------------------------
    Func _WinFadeOut($hGui,$timertime = 20 ,$blendzize = 0.75 )
    WinSetTrans($hGui, "",255)
    $i = 255
    $timerinit = TimerInit()
    Do
    If TimerDiff($timerinit) > $timertime Then
    $i = $i*$blendzize
    If $i < 5 Then ExitLoop
    WinSetTrans($hGui, "",$i)
    $timerinit = TimerInit()
    EndIf
    Until $i < 5
    WinSetTrans($hGui, "",0)
    GUISetState ( @SW_HIDE, $hGui)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Image aus dll
    ;-------------------------------------------------------------------------------------------------
    Func _SetImagefromResource($CtrlID, $Resname, $Resfile = -1, $ResType = 10)
    Local Const $IMAGE_BITMAP = 0
    Local Const $STM_SETIMAGE = 0x0172
    Local $hmod, $hwnd, $InfoBlock, $ResSize, $Mem, $pMem, $dll, $dll2, $hData, $pData, $pStream, $ret, $hBitmap, $pBitmap
    $hmod = _WinAPI_LoadLibrary($Resfile)
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP(_WinAPI_LoadImage($hmod, $Resname, $IMAGE_BITMAP, 0, 0, 0))
    ;~ If $ResType = 2 Then
    ;~ $hBitmap = _WinAPI_LoadImage($hmod, $Resname, $IMAGE_BITMAP, 0, 0, 0)
    ;~ If @error Then Return SetError(1, 0, 0)
    ;~ $hwnd = GUICtrlGetHandle($CtrlID)
    ;~ If $hwnd = 0 Then Return SetError(2, 0, 0)
    ;~ DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hwnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    ;~ If @error Then Return SetError(3, 0, 0)
    ;~ EndIf
    Return $hBitmap
    EndFunc

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

    Func Label()
    _GDIPlus_GraphicsDrawStringEx ($hBackbuffer, 'v. 2.0.1.64', $hFont_Label, $tLayout_Label, $hFormat_Label, $hBrush_Label)
    _GDIPlus_GraphicsDrawStringEx ($hBackbuffer, 'Lizenz: ---' & @CRLF & _
    'Beta Version'& @CRLF & _
    'C .Schiffer 2010', $hFont_Label, $tLayout_Label2, $hFormat_Label, $hBrush_Label2)
    EndFunc

    [/autoit]

    Du solltest dir angewöhnen die GDI+ Ressourcen wieder freizugeben, denn du hast damit ein Speicherfresser erzeugt! [Blockierte Grafik: http://www.autoit.de/wcf/images/smilies/13.gif]

    Die Fonts müssen auch nicht immer wieder neu erstellt werden...

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    Einmal editiert, zuletzt von UEZ (5. Juni 2010 um 19:05)

  • Zitat

    Nur eine Frage...wenn ich bei der Schrift den Alpha Kanal veränder dann muss ich die schrifft doch auch neu erstellen??


    Du kannst bei der Schrift nicht den Alpha Kanal verändern sondern nur beim BrushObjekt, und da kannst du das auch mit _GDIPlus_BrushSetSolidColor machen ohne den Brush neu erstellen zu müssen ;).

  • Servus...

    Danke für die Hilfe...
    Ich habe mal die fertige Version hier rein gestellt..

    Spoiler anzeigen
    [autoit]


    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <WinAPI.au3>
    #include <GDIPlus.au3>
    #include <StaticConstants.au3>

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

    Global Const $GuiStart_width = 430
    Global Const $GuiStart_height = 236
    Global Const $GuiStart_Pos_X = -1
    Global Const $GuiStart_Pos_Y = -1
    Global Const $Schriftgroesse = 11
    Global Const $Schriftart = 1
    Global Const $Version_Programm = "v. 2.0.1.64"
    Global Const $Rechts_Unten = 'Lizenz: ----' & @CRLF & _
    'Beta Version'&@CRLF& _
    'C .Schiffer 2010'
    Dim $hGuiStart,$hFont_Label,$hFamily_Label,$hFormat_Label,$hBrush_Label,$hBackbuffer,$tLayout_Label2
    Dim $hImage,$hBrush_Label2,$hBackbuffer,$hGraphic,$hFormat_Label2,$hBitmap,$tLayout_Label

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

    _Intro()
    _WinFadeIn($hGuiStart)

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

    Sleep ( 300 )
    _StringFadeIn('Starte',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('Starte.',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte..',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte...',50,190)
    Sleep ( 200 )
    _StringSetNewText('Starte....',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('Starte....',50,190)

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

    _StringFadeIn('prüfe Daten',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten.',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten..',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten...',50,190)
    Sleep ( 200 )
    _StringSetNewText('prüfe Daten....',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('prüfe Daten....',50,190)

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

    _StringFadeIn('starte Server',50,190)
    ;--------------------------------------------------------------
    ; Hier kommt der zu verarbeitende Prozess rein...
    Sleep ( 200 )
    _StringSetNewText('starte Server (15%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (30%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (60%)',50,190)
    Sleep ( 200 )
    _StringSetNewText('starte Server (85%)',50,190)
    Sleep ( 200 )
    ;--------------------------------------------------------------
    _StringFadeOut('starte Server (100%)',50,190)

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

    Sleep (200)
    _WinFadeOut($hGuiStart)
    _IntroExit()
    ;-------------------------------------------------------------------------------------------------
    ; GDI Beenden
    ;-------------------------------------------------------------------------------------------------
    Func _IntroExit()
    _GDIPlus_FontDispose($hFont_Label)
    _GDIPlus_FontFamilyDispose($hFamily_Label)
    _GDIPlus_StringFormatDispose($hFormat_Label)
    _GDIPlus_StringFormatDispose($hFormat_Label2)
    _GDIPlus_BrushDispose($hBrush_Label)
    _GDIPlus_BrushDispose($hBrush_Label2)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown ()
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Intor erstellen
    ;-------------------------------------------------------------------------------------------------
    Func _Intro()
    $hGuiStart = GUICreate('', $GuiStart_width, $GuiStart_height ,$GuiStart_Pos_X,$GuiStart_Pos_y,$WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST))
    WinSetTrans($hGuiStart, "",0)
    GUISetState()
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGuiStart)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($GuiStart_width, $GuiStart_height, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    $hImage = _SetImagefromResource(0, "hg", "data.dll",2)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)

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

    $hBrush_Label = _GDIPlus_BrushCreateSolid (0xFFB0C4DE);blau
    $hBrush_Label2 = _GDIPlus_BrushCreateSolid (0xFF000000);schwarz
    $hFormat_Label = _GDIPlus_StringFormatCreate ()
    $hFormat_Label2 = _GDIPlus_StringFormatCreate ()
    _GDIPlus_StringFormatSetAlign($hFormat_Label2, 2)
    $hFamily_Label = _GDIPlus_FontFamilyCreate ("Arial")
    $hFont_Label = _GDIPlus_FontCreate ($hFamily_Label, 8, 0)
    $tLayout_Label = _GDIPlus_RectFCreate ($GuiStart_width - 58, 3, 100, 20)
    $tLayout_Label2 = _GDIPlus_RectFCreate ($GuiStart_width - 128, $GuiStart_height - 45, 120, 80)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic, $Version_Programm, $hFont_Label, $tLayout_Label, $hFormat_Label, $hBrush_Label)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic,$Rechts_Unten , $hFont_Label, $tLayout_Label2, $hFormat_Label2, $hBrush_Label2)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Label schreiben
    ;-------------------------------------------------------------------------------------------------
    Func Label()
    _GDIPlus_GraphicsDrawStringEx ($hBackbuffer, $Version_Programm, $hFont_Label, $tLayout_Label, $hFormat_Label, $hBrush_Label)
    _GDIPlus_GraphicsDrawStringEx ($hBackbuffer, $Rechts_Unten, $hFont_Label, $tLayout_Label2, $hFormat_Label2, $hBrush_Label2)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Verändern
    ;-------------------------------------------------------------------------------------------------
    Func _StringSetNewText($sString,$Pos_X,$Pos_Y)
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, 0, 0)
    Label()
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex(255, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, $Schriftgroesse, $Schriftart)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    $tLayout = _GDIPlus_RectFCreate( $Pos_X, $Pos_Y, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $GuiStart_width, $GuiStart_height)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; String Einblenden
    ;-------------------------------------------------------------------------------------------------
    Func _StringFadeIn($sString,$Pos_X,$Pos_Y,$Step = 25 ,$Time = 20 )
    $timerinit = TimerInit()
    For $i = 0 To 255 Step $Step
    Do
    Sleep (1)
    Until TimerDiff($timerinit) > $Time
    $timerinit = TimerInit()
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, 0, 0)
    Label()
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex($i, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, $Schriftgroesse-Round(((255/30)-($i/30)),0),$Schriftart)
    ;~ ConsoleWrite ( 11-((255/30)-($i/30))&@CRLF )
    If (255/6)-($i/6) < 2 Then
    $Pos_Y_Wert = $Pos_Y
    Else
    $Pos_Y_Wert = $Pos_Y+(255/6)-($i/6)
    EndIf
    $tLayout = _GDIPlus_RectFCreate( $Pos_X, $Pos_Y_Wert, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $GuiStart_width, $GuiStart_height)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    Next
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; String Ausblenden
    ;-------------------------------------------------------------------------------------------------
    Func _StringFadeOut($sString,$Pos_X,$Pos_Y,$Step = 25 ,$Time = 15)
    $timerinit = TimerInit()
    For $i = 255 To 0 Step -$Step
    If $i < 11 Then $i = 0
    Do
    Sleep (1)
    Until TimerDiff($timerinit) > $Time
    $timerinit = TimerInit()
    _GDIPlus_GraphicsDrawImage($hBackbuffer, $hImage, 0, 0)
    Label()
    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex($i, 2) & "FFFFFF")
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily,$Schriftgroesse-((255/30)-($i/30)), $Schriftart)
    ;~ ConsoleWrite ( 14-((255/30)-($i/30))&@CRLF )
    $Pos_Y_Wert = $Pos_Y-(255/10)+($i/10)
    $tLayout = _GDIPlus_RectFCreate($Pos_X, $Pos_Y_Wert, 0, 0)
    ;~ ConsoleWrite ( 190+(255/5)-($i/5)&@CRLF )
    $aInfo = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $GuiStart_width, $GuiStart_height)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    Next
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Gui Einblenden
    ;-------------------------------------------------------------------------------------------------
    Func _WinFadeIn($hGuiStart,$timertime = 20 ,$blendzize = 1.25 )
    WinSetTrans($hGuiStart, "",0)
    GUISetState ( @SW_SHOW, $hGuiStart)
    $i = 1
    $timerinit = TimerInit()
    Do
    If TimerDiff($timerinit) > $timertime Then
    $i = $i*$blendzize
    If $i > 255 Then ExitLoop
    WinSetTrans($hGuiStart, "",$i)
    $timerinit = TimerInit()
    EndIf
    Until $i > 255
    WinSetTrans($hGuiStart, "",255)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Gui Ausblenden
    ;-------------------------------------------------------------------------------------------------
    Func _WinFadeOut($hGuiStart,$timertime = 20 ,$blendzize = 0.75 )
    WinSetTrans($hGuiStart, "",255)
    $i = 255
    $timerinit = TimerInit()
    Do
    If TimerDiff($timerinit) > $timertime Then
    $i = $i*$blendzize
    If $i < 5 Then ExitLoop
    WinSetTrans($hGuiStart, "",$i)
    $timerinit = TimerInit()
    EndIf
    Until $i < 5
    WinSetTrans($hGuiStart, "",0)
    GUISetState ( @SW_HIDE, $hGuiStart)
    EndFunc

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

    ;-------------------------------------------------------------------------------------------------
    ; Image aus dll
    ;-------------------------------------------------------------------------------------------------
    Func _SetImagefromResource($CtrlID, $Resname, $Resfile = -1, $ResType = 10)
    Local Const $IMAGE_BITMAP = 0
    Local Const $STM_SETIMAGE = 0x0172
    Local $hmod, $hwnd, $InfoBlock, $ResSize, $Mem, $pMem, $dll, $dll2, $hData, $pData, $pStream, $ret, $hBitmap, $pBitmap
    $hmod = _WinAPI_LoadLibrary($Resfile)
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP(_WinAPI_LoadImage($hmod, $Resname, $IMAGE_BITMAP, 0, 0, 0))
    Return $hBitmap
    EndFunc

    [/autoit]

    dll im Anhang wird benötigt...

    MFG chris :D