Ist schon ne Weile her als ich mich zuletzt damit befasst habe. Hier mal eine beschnittene GUI aus meinem Programm (Die Bilder werden normalerweise von einer Webseite nachgeladen, das hab ich hier mal ausgebaut):
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <SendMessage.au3>
showbanners(6)
[/autoit] [autoit][/autoit] [autoit]Func showbanners($bilderzahl=1)
[/autoit] [autoit][/autoit] [autoit]Local $PicCtrlID[$bilderzahl]
[/autoit] [autoit][/autoit] [autoit]if $bilderzahl < 5 Then
$hoehe = ($bilderzahl*160) + 20
$breite = 758 + 40
Else
$hoehe = 660
$breite = 758 + 40 + 16
EndIf
$bannerGUI = GUICreate("Banner Auswahl",$breite,$hoehe,-1,-1)
[/autoit] [autoit][/autoit] [autoit];For $i = 0 to $bilderzahl-1
; $PicCtrlID[$i]=GUICtrlCreatePic(@ScriptDir & "\" & "loading.jpg",20,($i*160)+20,758,140)
;Next
if $bilderzahl > 4 Then
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_MOUSEWHEEL, "_Scrollbars_WM_MOUSEWHEEL")
;GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
_GUIScrollBars_Init($bannerGUI,-1,($bilderzahl*160)/16) ; die Gesamtpixelzahl muss immer durch 16 geteilt werden !!!
EndIf
GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
GUIDelete($bannerGUI)
Return -1
EndSwitch
;~ For $i = 0 To $bilderzahl-1
;~ if $msg = $PicCtrlID[$i] Then
;~ MsgBox(0,"Bild gewählt","Du hast Bild Nummer " & $i+1 & " gewählt.")
;~ GUIDelete($bannerGUI)
;~ Return $i
;~ EndIf
;~ Next
WEnd
EndFunc
[/autoit] [autoit][/autoit] [autoit]; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Scrollbars_WM_MOUSEWHEEL
; Description ...: GUIRegisterMsg procedure for vertical mouse wheel scroll
; Syntax ........: _Scrollbars_WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
; Return values .: None
; Author ........: Based on code from MrCreator & Malkey
; Remarks .......: This function is used internally by _Scrollbars_Generate
; ===============================================================================================================================
Func _Scrollbars_WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $lParam
Local $iDirn, $iDelta = BitShift($wParam, 16) ; Mouse wheel movement
If BitAND($wParam, 0x0000FFFF) Then ; If Ctrl or Shft pressed move Horz scrollbar
$iDirn = $SB_LINERIGHT
If $iDelta > 0 Then $iDirn = $SB_LINELEFT
For $i = 1 To 7
_SendMessage($hWnd, $WM_HSCROLL, $iDirn)
Next
Else ; Move Vert scrollbar
$iDirn = $SB_LINEDOWN
If $iDelta > 0 Then $iDirn = $SB_LINEUP
for $i = 1 to 7
_SendMessage($hWnd, $WM_VSCROLL, $iDirn)
Next
EndIf
[/autoit] [autoit][/autoit] [autoit]Return $GUI_RUNDEFMSG
[/autoit] [autoit][/autoit] [autoit]EndFunc ;==>_Scrollbars_WM_MOUSEWHEEL
[/autoit] [autoit][/autoit] [autoit]Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam
Local $index = -1, $yChar, $xChar, $xClientMax, $xClient, $yClient, $ivMax
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x][0] = $hWnd Then
$index = $x
$xClientMax = $aSB_WindowInfo[$index][1]
$xChar = $aSB_WindowInfo[$index][2]
$yChar = $aSB_WindowInfo[$index][3]
$ivMax = $aSB_WindowInfo[$index][7]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)
[/autoit] [autoit][/autoit] [autoit]; Retrieve the dimensions of the client area.
$xClient = BitAND($lParam, 0x0000FFFF)
$yClient = BitShift($lParam, 16)
$aSB_WindowInfo[$index][4] = $xClient
$aSB_WindowInfo[$index][5] = $yClient
; Set the vertical scrolling range and page size
DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
DllStructSetData($tSCROLLINFO, "nMin", 0)
DllStructSetData($tSCROLLINFO, "nMax", $ivMax)
DllStructSetData($tSCROLLINFO, "nPage", $yClient / $yChar)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
; Set the horizontal scrolling range and page size
DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
DllStructSetData($tSCROLLINFO, "nMin", 0)
DllStructSetData($tSCROLLINFO, "nMax", 2 + $xClientMax / $xChar)
DllStructSetData($tSCROLLINFO, "nPage", $xClient / $xChar)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam, $lParam
Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
Local $index = -1, $yChar, $yPos
Local $Min, $Max, $Page, $Pos, $TrackPos
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x][0] = $hWnd Then
$index = $x
$yChar = $aSB_WindowInfo[$index][3]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
; 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")
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 - 1)
Case $SB_LINEDOWN ; user clicked the bottom arrow
DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
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", $TrackPos)
EndSwitch
;~ // 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")
If ($Pos <> $yPos) Then
_GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
$yPos = $Pos
EndIf
Return $GUI_RUNDEFMSG
[/autoit] [autoit][/autoit] [autoit]EndFunc ;==>WM_VSCROLL
[/autoit] [autoit][/autoit] [autoit]Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $lParam
Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
Local $index = -1, $xChar, $xPos
Local $Min, $Max, $Page, $Pos, $TrackPos
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x][0] = $hWnd Then
$index = $x
$xChar = $aSB_WindowInfo[$index][2]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
;~ ; Get all the horizontal 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
$xPos = DllStructGetData($tSCROLLINFO, "nPos")
$Pos = $xPos
$TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
#forceref $Min, $Max
Switch $nScrollCode
Case $SB_LINELEFT ; user clicked left arrow
DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
Case $SB_LINERIGHT ; user clicked right arrow
DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
Case $SB_THUMBTRACK ; user dragged the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
EndSwitch
;~ // 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")
If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_HSCROLL