Anpinnen von variablen Seitenleisten

  • Hallo allerseits!

    Ich bin mir sicher, es gibt eine UDF dafür, aber das englische Forum ist ja down... :rolleyes:

    Ich würde gerne soetwas ähnliches wie hier machen:
    autoit.de/wcf/attachment/5549/

    Man kann Seitenleisten, die sich ein und ausklappen können anpinnen.

    Kann ich sowas auch umsetzen? Oder sprengt das die Möglichkeiten von AutoIt?

    Schönen Sonntag noch!
    Matthias

  • ich denke ich habe genau sowas im engl. Forum schon gesehen.
    Musste halt bis morgen warten...

    Edit: Uppsss
    Beim 2. mal lesen von Deinem Thread hab ich erst gesehen, dass ich was übersehen hab.
    Das mit dem Pin ist in der Demo nicht mit drin. Daher wieder gelöscht ;)

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

    Einmal editiert, zuletzt von Schnuffel (26. Juli 2009 um 22:06)

  • Hallo nochmal!
    Erstmal danke für die rege Beteiligung :D

    BugFix : Sag mir bitte bescheid, wenn ich grad falsch liege. Aber bei mir handelt es sich doch um eine Seitenleiste innerhalb des Fensters.

    Mir ist grad eine Idee gekommen, ich könnte doch dafür eine ChildGui einsetzen, die man immer wegklicken kann. Mein Problem: Ich habe davon sowas von keine Erfahrung. Also hier meine aktualisierte Fragenliste:

    1. Wie positioniere ich eine ChildGUI genau?
    2. Wie kann ich diese ChildGUI ausblenden (möglichst animiert ;) ) und den Platz für andere Seteuerelemente freigeben? Geht WinMove?
    3. Wie kann ich abfragen, ob die GUI sichtbar ist oder nicht? Oder muss ich immer eine Variable setzen?

    • Offizieller Beitrag

    Ah, OK - da hast du recht. :D

    Hier mal ein Bsp. mit Child-Window.

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("GUIOnEventMode", 1)

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

    Global Const $AW_SLIDE = 0x40000
    Global Const $AW_HOR_POSITIVE = 0x1 ; left to right
    Global Const $AW_HOR_NEGATIVE = 0x2 ; right to left
    Global Const $AW_ACTIVATE = 0x20000 ; Activates the window
    Global Const $AW_HIDE = 0x10000
    Global $hWnd

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

    $GUImain = GUICreate('Main', 800, 600, -1, -1, Default, $GUI_WS_EX_PARENTDRAG)
    GUISetOnEvent(-3, '_ende')
    $btPinn = GUICtrlCreateButton('', 770, 10, 15, 15)
    GUICtrlSetOnEvent(-1, "_show")
    GUICtrlCreateEdit('PINN', 770, 30, 15, 60, BitOR($ES_CENTER,$ES_MULTILINE,$ES_READONLY))

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

    $GUIchild = GUICreate("", 596, 578, 200, 0, Default, $WS_EX_MDICHILD, $GUImain)
    GUISetOnEvent(-3, "_hide")
    $hWnd = WinGetHandle($GUIchild)

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

    GUISetState(@SW_SHOW, $GUImain)

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

    While 1
    Sleep(100)
    WEnd

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

    Func _ende()
    Exit
    EndFunc

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

    Func _show()
    AnimateWindow($hWnd, BitOR($AW_SLIDE, $AW_ACTIVATE, $AW_HOR_NEGATIVE))
    EndFunc

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

    Func _hide()
    AnimateWindow($hWnd, BitOR($AW_SLIDE, $AW_HIDE, $AW_HOR_POSITIVE))
    EndFunc

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

    Func AnimateWindow($hWnd, $dwFlags, $dwTime=200)
    DllCall("user32", 'long', 'AnimateWindow', 'hwnd', $hWnd, 'long', $dwTime, 'long', $dwFlags)
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Ich habe es mal noch grafisch aufgewertet ;)

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("GUIOnEventMode", 1)

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

    Global Const $AW_SLIDE = 0x40000
    Global Const $AW_HOR_POSITIVE = 0x1 ; left to right
    Global Const $AW_HOR_NEGATIVE = 0x2 ; right to left
    Global Const $AW_ACTIVATE = 0x20000 ; Activates the window
    Global Const $AW_HIDE = 0x10000
    Global Const $iPI = 3.1415926535897932384626433832795
    Global $aChild[3], $aLbl[3], $aGraphics[3], $hWnd, $closehWnd = 0
    Local $iHTitel = _WinAPI_GetSystemMetrics(4), $iWBorder = _WinAPI_GetSystemMetrics(32)+_WinAPI_GetSystemMetrics(5)
    Local $iWMain = 800, $iHMain = 600, $iWChild = 200, $iHChild = $iHMain-$iHTitel

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

    _GDIPlus_Startup()

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

    $guiMain = GUICreate('Main', $iWMain, $iHMain, -1, -1, Default, $GUI_WS_EX_PARENTDRAG)
    $hWnd = WinGetHandle($guiMain)
    GUISetOnEvent(-3, '_ende')
    $aLbl[0] = GUICtrlCreateLabel('', $iWMain-20, 0, 18, 70)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent(-1, "_show")
    $aLbl[1] = GUICtrlCreateLabel('', $iWMain-20, 72, 18, 70)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent(-1, "_show")
    $aLbl[2] = GUICtrlCreateLabel('', $iWMain-20, 144, 18, 70)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent(-1, "_show")
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($guiMain)

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

    $aChild[0] = GUICreate("Child 1", $iWChild, $iHChild-$iWBorder, $iWMain-$iWChild-$iWBorder-21, 0, _
    $WS_CAPTION, $WS_EX_MDICHILD, $guiMain)

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

    $aChild[1] = GUICreate("Child 2", $iWChild, $iHChild-$iWBorder, $iWMain-$iWChild-$iWBorder-21, 0, _
    $WS_CAPTION, $WS_EX_MDICHILD, $guiMain)

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

    $aChild[2] = GUICreate("Child 3", $iWChild, $iHChild-$iWBorder, $iWMain-$iWChild-$iWBorder-21, 0, _
    $WS_CAPTION, $WS_EX_MDICHILD, $guiMain)

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

    GUISetState(@SW_SHOW, $GUImain)

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

    GDIPlus_SetAngledText($hGraphics, 'Pinn 1', 790, 35, 270, "Courier New", 12, 0xFF0000FF)
    GDIPlus_SetAngledText($hGraphics, 'Pinn 2', 790, 107, 270, "Courier New", 12, 0xFF0000FF)
    GDIPlus_SetAngledText($hGraphics, 'Pinn 3', 790, 179, 270, "Courier New", 12, 0xFF0000FF)

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

    While 1
    Sleep(100)
    WEnd

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

    Func _ende()
    Exit
    EndFunc

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

    Func _show()
    Local $ID = @GUI_CtrlId
    For $i = 0 To UBound($aChild) -1
    If ($aLbl[$i] = $ID) And (WinGetState($aChild[$i]) > 5) Then
    $closehWnd = WinGetHandle($aChild[$i])
    Return _hide()
    EndIf
    Next
    For $i = 0 To UBound($aLbl) -1
    If $aLbl[$i] = $ID Then _slideIn(WinGetHandle($aChild[$i]))
    Next
    For $i = 0 To UBound($aChild) -1
    If ($aLbl[$i] <> $ID) And (WinGetState($aChild[$i]) > 5) Then
    $closehWnd = WinGetHandle($aChild[$i])
    Return _hide()
    EndIf
    Next
    EndFunc

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

    Func _hide()
    Local $hWnd = @GUI_WinHandle
    If $closehWnd Then
    $hWnd = $closehWnd
    $closehWnd = 0
    EndIf
    Return _slideOut($hWnd)
    EndFunc

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

    Func _slideIn($hWnd)
    AnimateWindow($hWnd, BitOR($AW_SLIDE, $AW_ACTIVATE, $AW_HOR_NEGATIVE))
    EndFunc

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

    Func _slideOut($hWnd)
    AnimateWindow($hWnd, BitOR($AW_SLIDE, $AW_HIDE, $AW_HOR_POSITIVE))
    EndFunc

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

    Func AnimateWindow($hWnd, $dwFlags, $dwTime=100)
    DllCall("user32", 'long', 'AnimateWindow', 'hwnd', $hWnd, 'long', $dwTime, 'long', $dwFlags)
    EndFunc

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

    ; #FUNCTION# ================================================================
    ; Name...........: GDIPlus_SetAngledText
    ; Description ...: Adds text to a graphic object at any angle.
    ; Syntax.........: GDIPlus_SetAngledText($hGraphic, $nText, [$iCentreX, [$iCentreY, [$iAngle , [$nFontName , _
    ; [$nFontSize, [$iARGB, [$iAnchor]]]]]]] )
    ; Parameters ....: $hGraphic - The Graphics object to receive the added text.
    ; $nText - Text string to be displayed
    ; $iCentreX - Horizontal coordinate of horixontal centre of the text rectangle (default = 0 )
    ; $iCentreY - Vertical coordinate of vertical centre of the text rectangle (default = 0 )
    ; $iAngle - The angle which the text will be place in degrees. (default = "" or blank = 0 )
    ; $nFontName - The name of the font to be used (default = "" or Blank = "Arial" )
    ; $nFontSize - The font size to be used (default = "" or Blank = 12 )
    ; $iARGB - Alpha(Transparency), Red, Green and Blue color (0xAARRGGBB) (Default= "" = random color
    ; or Default = Blank = 0xFFFF00FF )
    ; $iAnchor - If zero (default) positioning $iCentreX, $iCentreY values refer to centre of text string.
    ; If not zero positioning $iCentreX, $iCentreY values refer to top left corner of text string.
    ; Return values .: 1
    ; Author ........: Malkey
    ; Modified.......:
    ; Remarks .......: Call _GDIPlus_Startup() before starting this function, and call _GDIPlus_Shutdown()after function ends.
    ; Can enter calculation for Angle Eg. For incline, -ATan($iVDist / $iHDist) * 180 / $iPI , where
    ; $iVDist is Vertical Distance, $iHDist is Horizontal Distance, and, $iPI is Pi, (an added Global Const).
    ; When used with other graphics, call this function last. The MatrixRotate() may affect following graphics.
    ; Related .......: _GDIPlus_Startup(), _GDIPlus_Shutdown(), _GDIPlus_GraphicsDispose($hGraphic)
    ; Link ..........;
    ; Example .......; Yes
    ; ========================================================================================
    Func GDIPlus_SetAngledText($hGraphic, $nText, $iCentreX = 0, $iCentreY = 0, $iAngle = 0, $nFontName = "Arial", _
    $nFontSize = 12, $iARGB = 0xFFFF00FF, $iAnchor = 0)
    Local $x, $y, $iX, $iY, $iWidth, $iHeight
    Local $hMatrix, $iXt, $iYt, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

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

    ; Default values
    If $iAngle = "" Then $iAngle = 0
    If $nFontName = "" Or $nFontName = -1 Then $nFontName = "Arial" ; "Microsoft Sans Serif"
    If $nFontSize = "" Then $nFontSize = 12
    If $iARGB = "" Then ; Randomize ARGB color
    $iARGB = "0xFF" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2)
    EndIf

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

    $hFormat = _GDIPlus_StringFormatCreate(0)
    $hFamily = _GDIPlus_FontFamilyCreate($nFontName)
    $hFont = _GDIPlus_FontCreate($hFamily, $nFontSize, 1, 3)
    $tLayout = _GDIPlus_RectFCreate($iCentreX, $iCentreY, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
    $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
    $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))

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

    ;Later calculations based on centre of Text rectangle.
    If $iAnchor = 0 Then ; Reference to middle of Text rectangle
    $iX = $iCentreX
    $iY = $iCentreY
    Else ; Referenced centre point moved to top left corner of text string.
    $iX = $iCentreX + (($iWidth - Abs($iHeight * Sin($iAngle * $iPI / 180))) / 2)
    $iY = $iCentreY + (($iHeight + Abs($iWidth * Sin($iAngle * $iPI / 180))) / 2)
    EndIf

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

    ;Rotation Matrix
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, $iAngle, 1)
    _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)

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

    ;x, y are display coordinates of center of width and height of the rectanglular text box.
    ;Top left corner coordinates rotate in a circular path with radius = (width of text box)/2.
    ;Parametric equations for a circle, and adjustments for centre of text box
    $x = ($iWidth / 2) * Cos($iAngle * $iPI / 180) - ($iHeight / 2) * Sin($iAngle * $iPI / 180)
    $y = ($iWidth / 2) * Sin($iAngle * $iPI / 180) + ($iHeight / 2) * Cos($iAngle * $iPI / 180)

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

    ;Rotation of Coordinate Axes formulae - To display at x and y after rotation, we need to enter the
    ;x an y position values of where they rotated from. This is done by rotating the coordinate axes.
    ;Use $iXt, $iYt in _GDIPlus_RectFCreate. These x, y values is the position of the rectangular
    ;text box point before rotation. (before translation of the matrix)
    $iXt = ($iX - $x) * Cos($iAngle * $iPI / 180) + ($iY - $y) * Sin($iAngle * $iPI / 180)
    $iYt = -($iX - $x) * Sin($iAngle * $iPI / 180) + ($iY - $y) * Cos($iAngle * $iPI / 180)

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

    $hBrush = _GDIPlus_BrushCreateSolid($iARGB)
    $tLayout = _GDIPlus_RectFCreate($iXt, $iYt, $iWidth, $iHeight)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $nText, $hFont, $tLayout, $hFormat, $hBrush)

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

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    $tLayout = ""
    Return 1
    EndFunc ;==>GDIPlus_SetAngledText

    [/autoit]
  • Was würde ich nur ohne dich machen? :D

    Ich werde wenn ich wieder da bin, mir das ganz genau anschauen. Ich werde dann $WS_POPUP nutzen, damit die Ränder nicht da sind, und das dann so ändern. Dann habe ich jetzt folgendes Problem: Im Fenster befindet sich ein SciLexer, der dann Platz machen soll, bzw. sich ausdehnen soll. Wie umsetzen ?(

    Eine schöne (Ferien-)Woche noch!
    Matthias

    • Offizieller Beitrag

    Meinst du so:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt("GUIOnEventMode", 1)

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

    Global Const $AW_SLIDE = 0x40000
    Global Const $AW_HOR_POSITIVE = 0x1 ; left to right
    Global Const $AW_HOR_NEGATIVE = 0x2 ; right to left
    Global Const $AW_ACTIVATE = 0x20000 ; Activates the window
    Global Const $AW_HIDE = 0x10000
    Global Const $iPI = 3.1415926535897932384626433832795
    Global $aChild[3], $aLbl[3], $aGraphics[3], $hWnd, $guiMain, $edit, $closehWnd = 0
    Local $iHTitel = _WinAPI_GetSystemMetrics(4), $iWBorder = _WinAPI_GetSystemMetrics(32)+_WinAPI_GetSystemMetrics(5)
    Local $iWMain = 800, $iHMain = 600, $iWChild = 200, $iHChild = $iHMain-$iHTitel

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

    _GDIPlus_Startup()

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

    $guiMain = GUICreate('Main', $iWMain, $iHMain, -1, -1, Default, $GUI_WS_EX_PARENTDRAG)
    $hWnd = WinGetHandle($guiMain)
    GUISetOnEvent(-3, '_ende')
    $edit = GUICtrlCreateEdit('', 15, 15, $iWMain-50, $iHMain-30)
    $aLbl[0] = GUICtrlCreateLabel('', $iWMain-20, 0, 18, 70)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent(-1, "_show")
    $aLbl[1] = GUICtrlCreateLabel('', $iWMain-20, 72, 18, 70)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent(-1, "_show")
    $aLbl[2] = GUICtrlCreateLabel('', $iWMain-20, 144, 18, 70)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetOnEvent(-1, "_show")
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($guiMain)

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

    $aChild[0] = GUICreate("Child 1", $iWChild, $iHChild-$iWBorder, $iWMain-$iWChild-$iWBorder-21, 0, _
    $WS_CAPTION, $WS_EX_MDICHILD, $guiMain)

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

    $aChild[1] = GUICreate("Child 2", $iWChild, $iHChild-$iWBorder, $iWMain-$iWChild-$iWBorder-21, 0, _
    $WS_CAPTION, $WS_EX_MDICHILD, $guiMain)

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

    $aChild[2] = GUICreate("Child 3", $iWChild, $iHChild-$iWBorder, $iWMain-$iWChild-$iWBorder-21, 0, _
    $WS_CAPTION, $WS_EX_MDICHILD, $guiMain)

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

    GUISetState(@SW_SHOW, $GUImain)

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

    GDIPlus_SetAngledText($hGraphics, 'Pinn 1', 790, 35, 270, "Courier New", 12, 0xFF0000FF)
    GDIPlus_SetAngledText($hGraphics, 'Pinn 2', 790, 107, 270, "Courier New", 12, 0xFF0000FF)
    GDIPlus_SetAngledText($hGraphics, 'Pinn 3', 790, 179, 270, "Courier New", 12, 0xFF0000FF)

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

    While 1
    Sleep(100)
    WEnd

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

    Func _ende()
    Exit
    EndFunc

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

    Func _show()
    Local $ID = @GUI_CtrlId
    For $i = 0 To UBound($aChild) -1
    If ($aLbl[$i] = $ID) And (WinGetState($aChild[$i]) > 5) Then
    $closehWnd = WinGetHandle($aChild[$i])
    Return _hide()
    EndIf
    Next
    For $i = 0 To UBound($aLbl) -1
    If $aLbl[$i] = $ID Then _slideIn(WinGetHandle($aChild[$i]))
    Next
    For $i = 0 To UBound($aChild) -1
    If ($aLbl[$i] <> $ID) And (WinGetState($aChild[$i]) > 5) Then
    $closehWnd = WinGetHandle($aChild[$i])
    Return _hide()
    EndIf
    Next
    EndFunc

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

    Func _hide()
    Local $hWnd = @GUI_WinHandle
    If $closehWnd Then
    $hWnd = $closehWnd
    $closehWnd = 0
    EndIf
    Return _slideOut($hWnd)
    EndFunc

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

    Func _slideIn($hWnd)
    Local $width = $iWMain-30-$iWChild-$iWBorder-21
    ControlMove($guiMain, '', $edit, 15, 15, $width, $iHMain-30)
    AnimateWindow($hWnd, BitOR($AW_SLIDE, $AW_ACTIVATE, $AW_HOR_NEGATIVE))
    EndFunc

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

    Func _slideOut($hWnd)
    AnimateWindow($hWnd, BitOR($AW_SLIDE, $AW_HIDE, $AW_HOR_POSITIVE))
    Local $width = $iWMain-50
    ControlMove($guiMain, '', $edit, 15, 15, $width, $iHMain-30)
    EndFunc

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

    Func AnimateWindow($hWnd, $dwFlags, $dwTime=100)
    DllCall("user32", 'long', 'AnimateWindow', 'hwnd', $hWnd, 'long', $dwTime, 'long', $dwFlags)
    EndFunc

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

    ; #FUNCTION# ================================================================
    ; Name...........: GDIPlus_SetAngledText
    ; Description ...: Adds text to a graphic object at any angle.
    ; Syntax.........: GDIPlus_SetAngledText($hGraphic, $nText, [$iCentreX, [$iCentreY, [$iAngle , [$nFontName , _
    ; [$nFontSize, [$iARGB, [$iAnchor]]]]]]] )
    ; Parameters ....: $hGraphic - The Graphics object to receive the added text.
    ; $nText - Text string to be displayed
    ; $iCentreX - Horizontal coordinate of horixontal centre of the text rectangle (default = 0 )
    ; $iCentreY - Vertical coordinate of vertical centre of the text rectangle (default = 0 )
    ; $iAngle - The angle which the text will be place in degrees. (default = "" or blank = 0 )
    ; $nFontName - The name of the font to be used (default = "" or Blank = "Arial" )
    ; $nFontSize - The font size to be used (default = "" or Blank = 12 )
    ; $iARGB - Alpha(Transparency), Red, Green and Blue color (0xAARRGGBB) (Default= "" = random color
    ; or Default = Blank = 0xFFFF00FF )
    ; $iAnchor - If zero (default) positioning $iCentreX, $iCentreY values refer to centre of text string.
    ; If not zero positioning $iCentreX, $iCentreY values refer to top left corner of text string.
    ; Return values .: 1
    ; Author ........: Malkey
    ; Modified.......:
    ; Remarks .......: Call _GDIPlus_Startup() before starting this function, and call _GDIPlus_Shutdown()after function ends.
    ; Can enter calculation for Angle Eg. For incline, -ATan($iVDist / $iHDist) * 180 / $iPI , where
    ; $iVDist is Vertical Distance, $iHDist is Horizontal Distance, and, $iPI is Pi, (an added Global Const).
    ; When used with other graphics, call this function last. The MatrixRotate() may affect following graphics.
    ; Related .......: _GDIPlus_Startup(), _GDIPlus_Shutdown(), _GDIPlus_GraphicsDispose($hGraphic)
    ; Link ..........;
    ; Example .......; Yes
    ; ========================================================================================
    Func GDIPlus_SetAngledText($hGraphic, $nText, $iCentreX = 0, $iCentreY = 0, $iAngle = 0, $nFontName = "Arial", _
    $nFontSize = 12, $iARGB = 0xFFFF00FF, $iAnchor = 0)
    Local $x, $y, $iX, $iY, $iWidth, $iHeight
    Local $hMatrix, $iXt, $iYt, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

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

    ; Default values
    If $iAngle = "" Then $iAngle = 0
    If $nFontName = "" Or $nFontName = -1 Then $nFontName = "Arial" ; "Microsoft Sans Serif"
    If $nFontSize = "" Then $nFontSize = 12
    If $iARGB = "" Then ; Randomize ARGB color
    $iARGB = "0xFF" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2)
    EndIf

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

    $hFormat = _GDIPlus_StringFormatCreate(0)
    $hFamily = _GDIPlus_FontFamilyCreate($nFontName)
    $hFont = _GDIPlus_FontCreate($hFamily, $nFontSize, 1, 3)
    $tLayout = _GDIPlus_RectFCreate($iCentreX, $iCentreY, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
    $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
    $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))

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

    ;Later calculations based on centre of Text rectangle.
    If $iAnchor = 0 Then ; Reference to middle of Text rectangle
    $iX = $iCentreX
    $iY = $iCentreY
    Else ; Referenced centre point moved to top left corner of text string.
    $iX = $iCentreX + (($iWidth - Abs($iHeight * Sin($iAngle * $iPI / 180))) / 2)
    $iY = $iCentreY + (($iHeight + Abs($iWidth * Sin($iAngle * $iPI / 180))) / 2)
    EndIf

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

    ;Rotation Matrix
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, $iAngle, 1)
    _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)

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

    ;x, y are display coordinates of center of width and height of the rectanglular text box.
    ;Top left corner coordinates rotate in a circular path with radius = (width of text box)/2.
    ;Parametric equations for a circle, and adjustments for centre of text box
    $x = ($iWidth / 2) * Cos($iAngle * $iPI / 180) - ($iHeight / 2) * Sin($iAngle * $iPI / 180)
    $y = ($iWidth / 2) * Sin($iAngle * $iPI / 180) + ($iHeight / 2) * Cos($iAngle * $iPI / 180)

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

    ;Rotation of Coordinate Axes formulae - To display at x and y after rotation, we need to enter the
    ;x an y position values of where they rotated from. This is done by rotating the coordinate axes.
    ;Use $iXt, $iYt in _GDIPlus_RectFCreate. These x, y values is the position of the rectangular
    ;text box point before rotation. (before translation of the matrix)
    $iXt = ($iX - $x) * Cos($iAngle * $iPI / 180) + ($iY - $y) * Sin($iAngle * $iPI / 180)
    $iYt = -($iX - $x) * Sin($iAngle * $iPI / 180) + ($iY - $y) * Cos($iAngle * $iPI / 180)

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

    $hBrush = _GDIPlus_BrushCreateSolid($iARGB)
    $tLayout = _GDIPlus_RectFCreate($iXt, $iYt, $iWidth, $iHeight)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $nText, $hFont, $tLayout, $hFormat, $hBrush)

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

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    $tLayout = ""
    Return 1
    EndFunc ;==>GDIPlus_SetAngledText

    [/autoit]
  • Ja genau! Wenn ich wieder da bin, werde ich das mal mit dem SciLexer ausprobieren.
    Danke ;)

  • Nö, wieso sollte ich "pfriemeln", ich brauch doch nur ein Child :P

    Edit: Verdammt! Ich brauche 2 :whistling: Naja, also doch "pfriemeln" :D

  • Ist echt cool.

    Hab die _Show() Funktion etwas angepasst:

    Spoiler anzeigen
    [autoit]


    Func _show()
    Local $ID = @GUI_CtrlId

    For $i = 0 To UBound($aChild) -1
    If ($aLbl[$i] <> $ID) And (WinGetState($aChild[$i]) > 5) Then
    $closehWnd = WinGetHandle($aChild[$i])
    _hide()
    EndIf
    Next
    For $i = 0 To UBound($aChild) -1
    If ($aLbl[$i] = $ID) And (WinGetState($aChild[$i]) > 5) Then
    $closehWnd = WinGetHandle($aChild[$i])
    Return _hide()
    EndIf
    Next
    For $i = 0 To UBound($aLbl) -1
    If $aLbl[$i] = $ID Then _slideIn(WinGetHandle($aChild[$i]))
    Next

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

    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von nuts (28. Juli 2009 um 21:21)