Fenster-Problem: verschiebar, in der mitte durchsichtig

  • Hi zusammen

    Also ich möchte ein Fenster erstellen, das man verschieben kann(nur an einem punkt), die Größe ändern kann(widht,height)(nur an einem punkt) und das nur den rahmen nicht durchsichtig hat. ich habe schon mit dem skript angefangen, aber trotz ist mir das ein bisschen zu schwrierig ^^.
    Bitte verbessert + verfolltständigt das skript :rolleyes:

    Spoiler anzeigen
    [autoit]

    #include "DrawTransparent.au3"
    #include <GUIConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    $height = 200
    $widht = 400
    $x = 2
    $y = 2
    $x_form = 4
    $y_form = 4
    $child_wh = 15

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

    $drag=GUICreate ("test", $widht+3, $height+3,$x_form,$y_form, $WS_POPUP, BitOR ( $WS_EX_TOPMOST, $WS_EX_COMPOSITED, $WS_EX_LAYERED ) )
    GUISetBkColor(0x000000)
    GUISetState()
    $Ellipse_close_P = _DrawRect($drag,$x+3,$y+3,2,2)
    $Ellipse_close = _DrawRect($drag,$x-5,$y-5,$child_wh,$child_wh,0x7EF955)

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

    $Ellipse_select_P = _DrawRect($drag,$widht-6,$height-6,2,2)
    $Ellipse_select = _DrawRect($drag,$widht-$child_wh+3,$height-$child_wh+3,$child_wh,$child_wh,0xFEF043)

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

    $Ellipse = _DrawTransparentRect($drag,$x,$y, $widht-2, $height-2)
    $Ellipse = _DrawTransparentRect($drag,$x+1,$y+1, $widht-2, $height-2)

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

    While 1
    $msg=GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    If WinActive($drag) Then
    $_drag = MouseGetPos()
    $x_drag = $_drag[0]
    $y_drag = $_drag[1]
    $_dragGUI = WinGetCaretPos()
    $x_dragGUI = $_dragGUI[0]
    $y_dragGUI = $_dragGUI[1]
    $x_diff = $x_drag - $x_dragGUI
    $y_diff = $y_drag - $x_dragGUI
    If $x_diff < $child_wh And $y_diff < $child_wh Then
    While _IsPressed(01)
    $_drag = MouseGetPos()
    $x_drag = $_drag[0]
    $y_drag = $_drag[1]
    WinMove($drag,"",$x_drag,$y_drag)
    WEnd
    EndIf
    $_drag2 = GUIGetMsg(1)
    $x_drag2 = $_drag2[3]
    $y_drag2 = $_drag2[4]
    If $x_drag2 <> 0 And Not StringInStr($x_drag2,"-") And $y_drag2 <> 0 And Not StringInStr($y_drag2,"-") And $x_drag2 < $widht And $y_drag2 < $height Then
    ;MsgBox(0,0,$x_drag2&" "&$y_drag2)
    EndIf
    EndIf
    WEnd

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

    Func _DrawRect($hwnd,$x,$y,$w,$h,$icolor = 0x000000)
    $Child=GUICreate("",$w,$h,$x,$y,$WS_CHILD,-1,$hwnd)
    GUISetBkColor($icolor, $Child)
    GUISetState()
    Return $Child
    EndFunc

    [/autoit]

    Die udf DrawTransperent:

    Spoiler anzeigen
    [autoit]

    #include-once
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPIError.au3>

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

    ;Global Const $WS_EX_COMPOSITED = 0x2000000
    ;Global Const $WS_EX_COMPOSITED = 0x2000000

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

    Func _DrawTransparentEllipse($hwnd, $x,$y,$w,$h,$Transparency=255)
    $Child=GUICreate ( "", $w, $h, $x, $y, $WS_CHILD, -1, $hwnd )
    _WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
    GUISetBkColor ( 0xABCDEF, $Child )
    _GuiRoundCorners ( $Child, 0, 0, $w, $h)
    GUISetState()
    Return $Child
    EndFunc

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

    Func _DeletTransparentForm ( $Form )
    If IsHWnd($Form) Then
    $a=GUIDelete($Form)
    Return $a
    Else
    $b=GUICtrlDelete($Form)
    Return $b
    EndIf
    EndFunc

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

    Func _DrawTransparentRect($hwnd, $x,$y,$w,$h,$Transparency=255)
    $Child=GUICreate ( "", $w, $h, $x, $y, $WS_CHILD, -1, $hwnd)
    _WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
    GUISetBkColor (0xABCDEF, $Child)
    GUISetState()
    Return $Child
    EndFunc

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

    Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    ; progandy
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
    If Not $isColorRef Then
    $i_transcolor = Hex(String($i_transcolor), 6)
    $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
    Case @error
    Return SetError(@error, 0, 0)
    Case $Ret[0] = 0
    Return SetError(4, _WinAPI_GetLastError(), 0)
    Case Else
    Return 1
    EndSelect
    EndFunc ;==>_WinAPI_SetLayeredWindowAttributes

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

    #cs
    Func _WinAPI_GetLastError()
    Local $aResult

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

    $aResult = DllCall("Kernel32.dll", "int", "GetLastError")
    If @error Then Return SetError(@error, 0, 0)
    Return $aResult[0]
    EndFunc ;==>_WinAPI_GetLastError
    #ce

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

    Func _GuiRoundCorners($hWnd, $x1, $y1, $x3, $y3)
    Local $pos, $ret, $ret2
    $pos = WinGetPos($hWnd)
    $ret = DllCall('gdi32.dll', 'long', 'CreateRoundRectRgn', 'long', $x1, 'long', $y1, 'long', $pos[2], 'long', $pos[3], 'long', $x3, 'long', $y3)
    If $ret[0] Then
    $ret2 = DllCall('user32.dll', 'long', 'SetWindowRgn', 'hwnd', $hWnd, 'long', $ret[0], 'int', 1)
    If $ret2[0] Then
    Return 1
    Else
    Return 0
    EndIf
    Else
    Return 0
    EndIf
    EndFunc

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

    Func _DrawTransparentLine($hwnd, $X,$Y,$length,$course,$pensize=2,$Transparency=255)
    _WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
    $g1=GUICtrlCreateGraphic($X,$Y,0,0)
    GUICtrlSetGraphic($g1, $GUI_GR_PENSIZE, $pensize )
    GUICtrlSetGraphic($g1, $GUI_GR_COLOR,0xABCDEF, 0xABCDEF)
    GUICtrlSetGraphic($g1, $GUI_GR_LINE, $length, $course)
    GUICtrlSetGraphic($g1, $GUI_GR_REFRESH)
    GUICtrlSetGraphic($g1, $GUI_GR_LINE, 1, 1)
    Return $g1
    EndFunc

    [/autoit]

    thx im vorraus :thumbup:

    Nur keine Hektik - das Leben ist stressig genug

    Einmal editiert, zuletzt von Antispeed (22. April 2010 um 18:05)

  • Hm, die UDF von mir ist schon alt, die geht glaubich nicht mal unter Vista, kann das nicht ausprobieren.

    Du kannst es so machen:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Transparent", 601, 201, 193, 125, $WS_POPUP+$WS_THICKFRAME, $WS_EX_LAYERED)
    $Pic1 = GUICtrlCreatePic("trans.JPG", 0, 0, 600, 200, BitOR($SS_NOTIFY,$WS_CLIPSIBLINGS))
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    GUICtrlCreateLabel("", 0, 0, 50, 50, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlSetState(-1, $GUI_ONTOP)
    GUISetState(@SW_SHOW)

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

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

    [/autoit]

    Brauch das Bild hier noch ( als trans.JPG speichern )

    [Blockierte Grafik: http://img408.imageshack.us/img408/125/transa.jpg]