Abend.
Ist es möglich, ein Label scrollbar zu machen?
Textfeld sieht einfach hässlich aus,
daher benutze ich ein Label.
In der Hilfe steht nix davon,
deswegen hoff ich auf eure Kniffe.
dankeschön,
dankeschön
Abend.
Ist es möglich, ein Label scrollbar zu machen?
Textfeld sieht einfach hässlich aus,
daher benutze ich ein Label.
In der Hilfe steht nix davon,
deswegen hoff ich auf eure Kniffe.
dankeschön,
dankeschön
Du benötigsr eine Scrollbar, einen Buffer für den Text und dann musst du je nach Position der Scrollbar die passenden Zeilen anzeigen.
ZitatScrollbar
Klingt alles logisch, aber mit welchem Befehl bekomm ich denn eine Scrollbar ?
Bei den guictrl* find ichs grade nicht...
Oder bin ich blind ?
Die Scrollbar-befehle gibt es in AutoIt nicht. Ich habe mal damit angefangen, aber die UDFs liegen auf meinem PC und an den komme ich gerade nicht ran.
Meinst du so was?
#include <timers.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
Local $GUIMsg, $hGUI, $label
Local $label_x = -50, $label_y = 120
$hGUI = GUICreate("GUI Test by UEZ 2010", 615, 469)
$Group1 = GUICtrlCreateGroup("Group1", 8, 8, 601, 113)
$Label1 = GUICtrlCreateLabel("Scrollbar Beispiel", 16, 24, 588, 87)
GUICtrlSetFont(-1, 56, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Group2", 8, 184, 601, 209)
$Button1 = GUICtrlCreateButton("Beenden", 56, 216, 507, 153)
GUICtrlSetFont(-1, 50, 400, 0, "Times New Roman")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Progress1 = GUICtrlCreateProgress(8, 410, 598, 40, 0x01) ;$PBS_SMOOTH)
GUISetBkColor(0x88AABB)
If @OSVersion = "WIN_XP" Then
$label = GUICtrlCreateLabel("Du kannst mich verschieben!", $label_x, $label_y, 2000, 60, Default, $WS_EX_COMPOSITED)
Else
$label = GUICtrlCreateLabel("Du kannst mich verschieben!", $label_x, $label_y, 2000, 60)
EndIf
GUICtrlSetFont(-1, 44)
GUISetState()
_GUIScrollBars_Init($hGUI)
_GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, False)
_GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, -500)
_GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, 600)
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
$i = 0
$j = 0.2
_Timer_SetTimer($hGUI, 10, "Progress")
While 1
$GUIMsg = GUIGetMsg()
Switch $GUIMsg
Case $GUI_EVENT_CLOSE, $Button1
_Timer_KillAllTimers($hGUI)
GUIDelete($hGUI)
ExitLoop
EndSwitch
WEnd
Exit
[/autoit] [autoit][/autoit] [autoit]Func Progress($hWnd, $Msg, $iIDTimer, $dwTime)
GUICtrlSetData($Progress1, $i)
$i += $j
If $i < 0 Or $i > 100 Then $j *= -1
EndFunc
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)
;// If the position has changed, scroll the window and update it
$Pos = DllStructGetData($tSCROLLINFO, "nPos")
GUICtrlSetPos($label, $label_x + $Pos, $label_y - 5)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_HSCROLL
Ist ein modifiziertes Beispiel aus der Hilfe.
Gruß,
UEZ
Hier das MSDN-Bsp. dazu.
Kannst du dir ja dann mal zu AutoIt portieren.
UEZ:
Das macht dann leider die gesamze GUI scrollbar,
nicht nur das label :\
BugFix :
Angeschaut und weggeklickt.
Ich habe absolut keinen Schimmer, wie ich das nach AutoIt portieren soll.
Das liegt vllt daran, dass ich auch dieses .dll-Zeug so gut wie nie verwende,
und ich mich daher bei sowas nicht auskenne...
Alles anzeigenUEZ:
Das macht dann leider die gesamze GUI scrollbar,
nicht nur das label :\BugFix :
Angeschaut und weggeklickt.
Ich habe absolut keinen Schimmer, wie ich das nach AutoIt portieren soll.
Das liegt vllt daran, dass ich auch dieses .dll-Zeug so gut wie nie verwende,
und ich mich daher bei sowas nicht auskenne...
Also bei mir bewegt sich nur das Label! Der Button bleibt doch auf der Stelle oder?
Gruß,
UEZ
UEZ: Also bei mir bewegt sich auch nur das Label, Vieleicht meint er ja das die Scrollbar irgendwie am label is oder so??
Guten Morgen,
da gibt es gerade ein wunderschönes Beispiel von Kleiner (GUI im GUI, ich hätte nicht im Traum daran gedacht, dass das so einfach geht). Ich habe das Beispiel von UEZ mal entsprechend umgestellt:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <StaticConstants.au3>
Local $GUIMsg, $hGUI, $label
[/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
GUISetBkColor(0x88AABB)
$button = GUICtrlCreateButton("Test", 100, 200, 200)
GUISetState()
$hScroll = GUICreate("", 380, 100, 10, 10, $WS_CHILD + $WS_BORDER, '', $hGUI)
GUISetBkColor(0x88AABB)
GUISetFont(50)
$label = GUICtrlCreateLabel("Test Test Test Test Test", 10, 10)
GUICtrlSetStyle(-1, $SS_CENTERIMAGE)
Global $aPos = ControlGetPos($hScroll, "", $label)
GUISetState()
_GUIScrollBars_Init($hScroll)
_GUIScrollBars_ShowScrollBar($hScroll, $SB_VERT, False)
Global $DeltaX = $aSB_WindowInfo[UBound($aSB_WindowInfo) - 1][2]
_GUIScrollBars_SetScrollRange($hScroll, $SB_HORZ, 0, Ceiling((($aPos[0] + $aPos[2] + $aPos[0]) / $DeltaX) - $DeltaX))
GUISetState()
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
[/autoit] [autoit][/autoit] [autoit]While 1
$GUIMsg = GUIGetMsg()
Switch $GUIMsg
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Exit
[/autoit] [autoit][/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
Ich habe auch den Code von Post #5 angepasst!
Da bewegt sich nur das Label und der Rest bleibt "stehen"!
Natürlich kann man auch "Child" GUIs nehmen, wie im Beispiel von Großvater und den Scrollbalken direkt darunter plazieren - ist anwendungsspezifisch!
Gruß,
UEZ