GUI mit Scrollbar

  • Hi,
    hab grad ein Problem mit einem Script.

    [autoit]


    #include<WindowsConstants.au3>
    #include<GuiconstantsEx.au3>
    #Include <GUIScroll.au3>

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

    $GUI = GUICreate("Test",400,300)
    GUISetState()

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

    $child = GUICreate("", 200, 200, -1, -1,BitOR ($WS_POPUP,$WS_BORDER), $WS_EX_TOPMOST )
    GUISetBkColor(0xFFFFFF)
    GUISetState()
    Scrollbar_Create($child, $SB_VERT, 700)

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

    Scrollbar_Step(20, $child, $SB_VERT)

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

    GUICtrlCreateButton("hello",50,200,120,23)

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

    While 1
    Sleep(50)
    WEnd

    [/autoit]

    Es funktioniert fast so wie ich es will.
    Aber gibt es vielleicht eine Möglichkeit alles nur in ein GUI zu machen oder so das man meint es wär eins?
    2. Problem ist das der Style $WS_EX_MDICHILD nicht mit der GUIScroll UDF genutzt werden kann und so beide GUIs unabhängig vonanander verschoben werden können.

    Vielleicht weis ja einer von euch wie sich beide Probleme lösen lassen. :)

    MfG

    Bladerunner

    Einmal editiert, zuletzt von Bladerunner85 (16. Juli 2010 um 11:41)

  • Du willst also ein GUI in einer GUI oder ?

    Dass müsste abhilfe schaffen.

    [autoit]


    $hMain = GUICreate("Main Gui")
    GUISetState()
    $hSub = GUICreate("Sub Gui")
    GUISetState()

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

    $Pos = WinGetPos($hMain)
    DllCall("user32.dll", "int", "SetParent", "hwnd", $hSub, "hwnd", $hMain)
    WinMove($hSub, "", 0, 0, $Pos[2], $Pos[3])

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

    While Sleep(100)
    WEnd

    [/autoit]


    und könntest du bitte mal GUIScroll.au3 anhängen ?

  • Hi,
    danke so hab ich mir das vorgestellt^^.

    Das Problem ist aber das ich jetzt das Parentfenster nur minimieren kann wenn auch das Childfenster minimiert ist.

    Weis jemand vielleicht auch dafür eine Lösung?

    MfG

    Bladerunner

  • Ich habs so versucht. Funzt leider nicht.

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>
    $hMain = GUICreate("Main Gui")
    GUISetState()
    $hSub = GUICreate("Sub Gui")
    GUISetState()

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

    $Pos = WinGetPos($hMain)
    DllCall("user32.dll", "int", "SetParent", "hwnd", $hSub, "hwnd", $hMain)
    WinMove($hSub, "", 0, 0, $Pos[2], $Pos[3])

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

    GUISwitch($hMain)
    While Sleep(100)
    Switch GUIGetMsg()
    Case -3
    Exit
    Case $GUI_EVENT_MINIMIZE
    ConsoleWrite(1 & @CRLF)
    GUISetState(@SW_MINIMIZE, $hSub)

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

    EndSwitch
    WEnd

    [/autoit]
  • Hallo

    schau dir [ gelöst ] Gruppe oder Bereich in GUI scrollen an, da funktionierts

    und hier die von mir verwendete GuiScroll.au3

    Spoiler anzeigen
    [autoit]

    #cs http://www.autoit.de/index.php?page…1092#post161092
    Functions:
    Scrollbar_Create($hWnd, $iBar, $iMax)
    Scrollbar_Scroll($hWnd, $iBar, $iPos)
    Scrollbar_GetPos($hWnd, $iBar)
    Scrollbar_Step($iStep, $hWnd=0, $iBar=0)
    #CE

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

    #Include <GuiScrollBars.au3>
    #include<GuiconstantsEx.au3>
    #include<WindowsConstants.au3>
    #include <ScrollBarConstants.au3>
    Global $SCROLL_AMOUNTS[1][3]
    $SCROLL_AMOUNTS[0][0] = 1
    func Scrollbar_Create($hWnd, $iBar, $iMax)

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

    Local $Size = WinGetClientSize($hWnd)

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

    If $iBar = $SB_HORZ Then
    $Size = $Size[0]
    ElseIf $iBar = $SB_VERT Then
    $Size = $Size[1]
    Else
    Return 0
    EndIf

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

    ReDim $SCROLL_AMOUNTS[UBound($SCROLL_AMOUNTS)+1][3]
    $SCROLL_AMOUNTS[UBound($SCROLL_AMOUNTS)-1][0] = $hWnd
    $SCROLL_AMOUNTS[UBound($SCROLL_AMOUNTS)-1][1] = $iBar
    $SCROLL_AMOUNTS[UBound($SCROLL_AMOUNTS)-1][2] = $SCROLL_AMOUNTS[0][0]

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

    _GUIScrollBars_EnableScrollBar($hWnd, $iBar)
    _GUIScrollBars_SetScrollRange($hWnd, $iBar, 0,$iMax-1)
    _GUIScrollBars_SetScrollInfoPage($hWnd, $iBar, $Size)

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

    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

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

    Return $iMax

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

    EndFunc
    Func Scrollbar_GetPos($hWnd, $iBar)

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

    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $iBar)

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

    Return DllStructGetData($tSCROLLINFO, "nPos")

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

    EndFunc
    Func Scrollbar_Scroll($hWnd, $iBar, $iPos)

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

    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $iBar)

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

    $iCurrentPos = DllStructGetData($tSCROLLINFO, "nPos")

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

    DllStructSetData($tSCROLLINFO, "nPos", $iPos)
    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $iBar, $tSCROLLINFO)

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

    If $iBar = $SB_VERT Then

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

    $iRound = 0

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

    for $i = 1 to UBound($SCROLL_AMOUNTS)-1
    If $SCROLL_AMOUNTS[$i][0] = $hWnd And $SCROLL_AMOUNTS[$i][1] = $SB_VERT Then
    $iRound = $SCROLL_AMOUNTS[$i][2]
    EndIf
    Next

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

    If Not $iRound Then Return 0

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

    _GUIScrollBars_ScrollWindow($hWnd, 0, Round(($iCurrentPos-$iPos)/$iRound)*$iRound)
    ElseIf $iBar = $SB_HORZ Then

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

    $iRound = 0

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

    for $i = 1 to UBound($SCROLL_AMOUNTS)-1
    If $SCROLL_AMOUNTS[$i][0] = $hWnd And $SCROLL_AMOUNTS[$i][1] = $SB_HORZ Then
    $iRound = $SCROLL_AMOUNTS[$i][2]
    EndIf
    Next

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

    If Not $iRound Then Return 0

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

    _GUIScrollBars_ScrollWindow($hWnd, Round(($iCurrentPos-$iPos)/$iRound)*$iRound, 0)
    Else
    Return 0
    EndIf

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

    Return 1

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

    EndFunc
    Func Scrollbar_Step($iStep, $hWnd=0, $iBar=0)

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

    If not $hWnd or Not $iBar Then

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

    $SCROLL_AMOUNTS[0][0] = $iStep
    Return 1

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

    EndIf

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

    $iID = 0

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

    for $i = 1 to UBound($SCROLL_AMOUNTS)-1
    If $SCROLL_AMOUNTS[$i][0] = $hWnd And $SCROLL_AMOUNTS[$i][1] = $iBar Then
    $iID = $i
    ExitLoop
    EndIf
    Next

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

    If Not $iID Then Return 0

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

    $SCROLL_AMOUNTS[$iID][2] = $iStep

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

    Return 1

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

    EndFunc
    Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)

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

    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $index = -1, $yChar, $yPos
    Local $Min, $Max, $Page, $Pos, $TrackPos
    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

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

    $iRound = 0

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

    for $i = 1 to UBound($SCROLL_AMOUNTS)-1
    If $SCROLL_AMOUNTS[$i][0] = $hWnd And $SCROLL_AMOUNTS[$i][1] = $SB_VERT Then
    $iRound = $SCROLL_AMOUNTS[$i][2]
    EndIf
    Next

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

    if Not $iRound Then Return $GUI_RUNDEFMSG

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

    Switch $nScrollCode
    Case $SB_TOP ; user clicked the HOME keyboard key
    DllStructSetData($tSCROLLINFO, "nPos", $Min)
    Case $SB_BOTTOM ; user clicked the END keyboard key
    DllStructSetData($tSCROLLINFO, "nPos", $Max)
    Case $SB_LINEUP ; user clicked the top arrow
    DllStructSetData($tSCROLLINFO, "nPos", $Pos - $iRound)
    Case $SB_LINEDOWN ; user clicked the bottom arrow
    DllStructSetData($tSCROLLINFO, "nPos", $Pos + $iRound)
    Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
    DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
    Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
    DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
    Case $SB_THUMBTRACK ; user dragged the scroll box
    DllStructSetData($tSCROLLINFO, "nPos", Round($TrackPos/$iRound)*$iRound)
    EndSwitch

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

    ;~ // Set the position and then retrieve it. Due to adjustments
    ;~ // by Windows it may not be the same as the value set.
    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")

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

    If ($Pos <> $yPos) Then
    _GUIScrollBars_ScrollWindow($hWnd, 0, $yPos - $Pos)
    EndIf
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_VSCROLL
    Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam)

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

    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $index = -1, $yChar, $yPos
    Local $Min, $Max, $Page, $Pos, $TrackPos
    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

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

    $iRound = 0

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

    for $i = 1 to UBound($SCROLL_AMOUNTS)-1
    If $SCROLL_AMOUNTS[$i][0] = $hWnd And $SCROLL_AMOUNTS[$i][1] = $SB_HORZ Then
    $iRound = $SCROLL_AMOUNTS[$i][2]
    EndIf
    Next

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

    if Not $iRound Then Return $GUI_RUNDEFMSG

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

    Switch $nScrollCode
    Case $SB_TOP ; user clicked the HOME keyboard key
    DllStructSetData($tSCROLLINFO, "nPos", $Min)
    Case $SB_BOTTOM ; user clicked the END keyboard key
    DllStructSetData($tSCROLLINFO, "nPos", $Max)
    Case $SB_LINEUP ; user clicked the top arrow
    DllStructSetData($tSCROLLINFO, "nPos", $Pos - $iRound)
    Case $SB_LINEDOWN ; user clicked the bottom arrow
    DllStructSetData($tSCROLLINFO, "nPos", $Pos + $iRound)
    Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
    DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
    Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
    DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
    Case $SB_THUMBTRACK ; user dragged the scroll box
    DllStructSetData($tSCROLLINFO, "nPos", Round($TrackPos/$iRound)*$iRound)
    EndSwitch

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

    ;~ // Set the position and then retrieve it. Due to adjustments
    ;~ // by Windows it may not be the same as the value set.
    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")

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

    If ($Pos <> $yPos) Then
    _GUIScrollBars_ScrollWindow($hWnd, $yPos - $Pos, 0)
    EndIf
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_HSCROLL

    [/autoit]

    mfg (Auto)Bert

  • Hi,
    danke für eure Antworten ;)

    Hab das Script das in Gruppe oder Bereich in GUI scrollen geposted wurde ein klein wenig verändert, sodass es mir gefällt.

    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GuiScroll.au3>

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

    Dim $idRadio2[100]

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

    $Form1 = GUICreate("Form1", 441, 441, 508, 269)
    GUISetState(@SW_SHOW)
    $hGroup2 = GUICreate("",170,170,235,25,BitOR($WS_POPUP, $WS_GROUP, $WS_VSCROLL, $WS_CLIPSIBLINGS),$WS_EX_MDICHILD,$Form1)
    GUISetState(@SW_SHOW)

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

    For $i = 0 to 99
    $idRadio2[$i] = GUICtrlCreateRadio("Radio " & $i, 5, $i*25, 60, 18)
    Next

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

    Scrollbar_Create($hGroup2, $SB_VERT, $i*25)
    Scrollbar_Step(20, $hGroup2, $SB_VERT)

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

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

    [/autoit]

    Wenn man aber das Script ausführt und auf das Symbol des Fensters in der Taskleiste klickt, sodas es verschwindet und es dann mit einem weiteren Klick wieder aktiviert, so sieht man das Childfenster einen Tick früher als das Parentfenster.
    Ist eigentlich nicht so schlimm sieht aber nen bisschen komisch aus^^.

    MfG

    Bladerunner