Что нового

[Элементы GUI] Прокрутка текста в табе

Firestarter

Новичок
Сообщения
54
Репутация
0
Добрый день. Возможно ли указать в данном скрипте прокрутку текста (если он не помещается в пределы таба) вверх/вниз одного из табов?

Код:
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIResizeMode", $GUI_DOCKRIGHT)

$Form1 = GUICreate("Form1", 598, 438, 192, 124)
$Tab1 = GUICtrlCreateTab(56, 84, 393, 353)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

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

	EndSwitch
WEnd
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Firestarter [?]
Возможно ли указать в данном скрипте прокрутку текста (если он не помещается в пределы таба) вверх/вниз одного из табов?
А текст в чем? (В каком элементе на TabItem ?)
 
Автор
F

Firestarter

Новичок
Сообщения
54
Репутация
0
Извиняюсь, вот полный скрипт:

Код:
#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Form1", 220, 120)
$Tab1 = GUICtrlCreateTab(10, 10, 200, 100)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")

$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlCreateLabel("Рекомендации по использованию:", 15, 40, 350, 14)
GUICtrlCreateLabel("1 -", 15, 60, 350, 14)
GUICtrlCreateLabel("2 -", 15, 80, 350, 14)
GUICtrlCreateLabel("3 -", 15, 100, 350, 14)
GUICtrlCreateLabel("4 -", 15, 120, 350, 14)
GUICtrlCreateLabel("5 -", 15, 140, 350, 14)

GUISetState()

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

    EndSwitch
WEnd
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Firestarter,
Попробуйте сделать примерно так.
Код:
#include <GUIConstantsEx.au3>
#include <StructureConstants.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>

Global $hGUI, $nTab, $iCountTab = 2, $iXt = 15, $iY = 10, $iWt = 200, $iHt = 100, $tRect, $iItemHt, $ahChildGUItab[$iCountTab], $iCurrentTab

$hGUI = GUICreate('Test', 220, 120)
$nTab = GUICtrlCreateTab($iXt, $iY, $iWt, $iHt)
For $i = 0 To $iCountTab - 1
	GUICtrlCreateTabItem('TabSheet' & $i)
	If Not $iItemHt Then
		$tRect = _GUICtrlTab_GetItemRectEx($nTab, 0)
		$iItemHt = DllStructGetData($tRect, 'Bottom')
		$tRect = 0
	EndIf
Next
GUICtrlCreateTabItem('')
GUICtrlSetPos($nTab, $iXt, $iY, $iWt, $iItemHt)
$iCurrentTab = GUICtrlRead($nTab)
GUISetState(@SW_SHOW, $hGUI)
For $i = 0 To $iCountTab - 1
	$ahChildGUItab[$i] = GUICreate('TabSheet' & $i, $iWt, $iHt - $iItemHt, $iXt, $iY + $iItemHt, $WS_CHILD, -1, $hGUI)
	GUISetBkColor(0x00BFFF * ($i + 1))
	GUICtrlCreateLabel('Рекомендации по использованию TabSheet' & $i & ':', 15, 40, 350, 14)
	For $j = 0 To 19
		GUICtrlCreateLabel($j + 1 & ' - TabSheet' & $i, 15, 60 + 20 * $j, 350, 14)
	Next
	If $i = $iCurrentTab Then
		GUISetState(@SW_SHOW, $ahChildGUItab[$i])
	Else
		GUISetState(@SW_HIDE, $ahChildGUItab[$i])
	EndIf
	_GUIScrollBars_Init($ahChildGUItab[$i])
Next

GUIRegisterMsg($WM_VSCROLL, 'WM_VSCROLL')
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
		Case $nTab
			$iCurrentTab = GUICtrlRead($nTab)
			For $i = 0 To $iCountTab - 1
				If $i = $iCurrentTab Then
					GUISetState(@SW_SHOW, $ahChildGUItab[$i])
				Else
					GUISetState(@SW_HIDE, $ahChildGUItab[$i])
				EndIf
			Next
	EndSwitch
WEnd

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

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

EndFunc   ;==>WM_VSCROLL
 
Верх