Что нового

[Элементы GUI] Вертикальная/Горизонтальная прокрутка с закрепленными областями.

XpycT

Скриптер
Сообщения
380
Репутация
133
Всем Привет

Есть GUI Форма
Код:
#Region Includes
#include <ScrollBarConstants.au3>
#include <StructureConstants.au3>
#include <Array.au3>
#include <Date.au3>
#include <GuiScrollBars.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#EndRegion Includes
Opt("TrayIconDebug", 0)
OnAutoItExitRegister("_Close")
#NoTrayIcon

Global $DebugModeStyle
Global $DebugMode_Style            = 1
If $DebugMode_Style = 1 Then $DebugModeStyle = $WS_BORDER

Global $fSize[7] = [10, 11, 12, 13, 14, 28, 38], $ffTahoma = "Tahoma"
Global $fwNormal = 400, $fwBold = 800, $fsNormal = 0, $fsItalic = 2
Global $cRed   = 0xFF0000, $cBlue  = 0x0000FF, $cGrey   = 0xDADBDD, $cGreen     = 0x008000
Global $cWhite = 0xFFFFFF, $cBlack = 0x000000, $cYellow = 0xFFFF00, $cLightGrey = 0x808080

Global $GUIWidth     = 1125, $GUIHeight = 830, $GUILeft = -1, $GUITop  = -1, $GUIbgColor = $cGrey, $GUIHeightCor = 0
Global $SectionWidth = $GUIWidth, $SectionHeight = $GUIHeight - 150

$hForm = GUICreate("Form", $GUIWidth, $GUIHeight, $GUILeft, $GUITop)
GUISetBkColor($GUIbgColor)

GUICtrlCreateLabel("F  O   R   M", 205, 5, $GUIWidth - 205, 65, BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle))
GUICtrlSetFont(-1, $fSize[6], $fwBold, $fsNormal, $ffTahoma)
GUICtrlSetColor(-1, $cBlue)

GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")

GUISetState(@SW_SHOW, $hForm)

_DateTable()

While 1
	$FormMsg = GUIGetMsg()

	If $FormMsg = $GUI_EVENT_CLOSE Then _Close()
WEnd

Func _DateTable()
	Local $sDatesList = @ScriptDir & "\DatesList.ini"

	$aPersonalList = IniReadSectionNames($sDatesList)

	Local $iDTHeadLeft = 0, $iDTHeadTop = 100, $iDTHeadWidth = $SectionWidth, $iDTHeadHeight = $SectionHeight, $GUIbgColor = $cGrey
	$hDTHead = GUICreate("Date Table Header", $iDTHeadWidth, $iDTHeadHeight, $iDTHeadLeft, $iDTHeadTop, $WS_CHILD, -1, $hForm)
	GUISetBkColor($GUIbgColor)

	Local $iHeadLeft = 5, $iHeadTop = 5, $iHeadWidth = 210, $iHeadHeighth = 105
	Local $iHeadStyle = BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle)
	GUICtrlCreateLabel("Имя", $iHeadLeft, $iHeadTop, $iHeadWidth, $iHeadHeighth, $iHeadStyle)
	GUICtrlSetBkColor(-1, $cRed)
	GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)
	GUICtrlCreateLabel("Дата", $iHeadLeft + 210, $iHeadTop, $iHeadWidth * 4 + 50, $iHeadHeighth, $iHeadStyle)
	GUICtrlSetBkColor(-1, $cBlue)
	GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)

	Local $iDTBodyLeft = 0, $iDTBodyTop = 110, $iDTBodyWidth = $iDTHeadWidth, $iDTBodyHeight = $iDTHeadHeight - $iDTBodyTop, $GUIbgColor = $cGrey
	$hDTBody = GUICreate("Date Table Body", $iDTBodyWidth, $iDTBodyHeight, $iDTBodyLeft, $iDTBodyTop, $WS_CHILD + $WS_VSCROLL, -1, $hDTHead)
	GUISetBkColor($GUIbgColor)

	Local $iPLLeft = 5, $iPLTop = 0, $iPLWidth = 210, $iPLHeight = 30
	For $p = 1 To $aPersonalList[0]
		GUICtrlCreateLabel($aPersonalList[$p], $iPLLeft, $iPLTop, $iPLWidth, $iPLHeight, BitOr($SS_CENTERIMAGE, $DebugModeStyle))
		GUICtrlSetBkColor(-1, $cYellow)
		GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)

		$iDate = IniRead($sDatesList, $aPersonalList[$p], "Date", "NA")
		GUICtrlCreateLabel($iDate, $iPLLeft + 210, $iPLTop, $iPLWidth * 4 + 50, $iPLHeight, BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle))
		GUICtrlSetBkColor(-1, $cGreen)
		GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)

		$iPLTop += 30
	Next

	_GUIScrollBars_Init($hDTBody, -1, Round($aPersonalList[0] * 1.84))

	GUISetState(@SW_SHOW, $hDTHead)
	GUISetState(@SW_SHOW, $hDTBody)

	GUISetState(@SW_SHOW, $hForm)
EndFunc   ;==>_PPC

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)

	; 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)

	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

EndFunc   ;==>WM_VSCROLL

Func _Close()
	Exit
EndFunc   ;==>_Close


На форму выводятся различные даты персонала, даты берутся из INI файла (для примера привел одну из дат, а на самом деле их около 30)
Пример INI файла (DatesList.ini)
INI:
[Person 01]
Date = 20.06.2008

[Person 02]
Date = 18.04.2004

[Person 03]
Date = 14.11.2006

[Person 04]
Date = 08.12.2001

[Person 05]
Date = 25.10.2003

[Person 06]
Date = 19.09.2002

[Person 07]
Date = 07.04.2008

[Person 08]
Date = 27.09.2002

[Person 09]
Date = 10.06.2004

[Person 10]
Date = 02.05.2007

[Person 11]
Date = 01.10.2008

[Person 12]
Date = 23.11.2007

[Person 13]
Date = 15.03.2005

[Person 14]
Date = 02.08.2009

[Person 15]
Date = 08.12.2002

[Person 16]
Date = 25.09.2007

[Person 17]
Date = 19.05.2000

[Person 18]
Date = 12.04.2008

[Person 19]
Date = 02.07.2006

[Person 20]
Date = 17.01.2003

[Person 21]
Date = 28.05.2000

[Person 22]
Date = 10.02.2003

[Person 23]
Date = 20.08.2004

[Person 24]
Date = 18.09.2004

[Person 25]
Date = 08.12.2007

[Person 26]
Date = 18.11.2009

[Person 27]
Date = 03.09.2003

[Person 28]
Date = 07.03.2006

[Person 29]
Date = 02.06.2007

[Person 30]
Date = 20.05.2003

[Person 31]
Date = 28.09.2007

Необходимо:
1. Сделать горизонтальную прокрутку так, что бы при прокрутке влево/вправо перемещались Синяя и Зеленая области, а Красная и Желтая оставались не подвижными.
2. Сделать вертикальную прокрутку так, что бы при прокрутке вверх/вниз перемещались Желтая и Зеленая области, а Красная и Синяя оставались не подвижными.

С вертикальной прокруткой вроде разобрался, но не уверен что правильно, хотя работает.

Помогите реализовать горизонтальную прокрутку. Заранее благодарен.
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,673
Репутация
2,484
XpycT [?]
Сделать горизонтальную прокрутку так, что бы при прокрутке влево/вправо перемещались Синяя и Зеленая области, а Красная и Желтая оставались не подвижными.
Нелогично. Как так можно перемещать кусок формы ;D Да и зачем?
Возможно имеется в виду перемещение содержимого таблицы прокруткой, а сам заголовок таблицы двигать только по горизонтали?

Код:
#Region Includes
#include <ScrollBarConstants.au3>
#include <StructureConstants.au3>
#include <Array.au3>
#include <Date.au3>
#include <GuiScrollBars.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#EndRegion Includes
;

Opt("TrayIconDebug", 0)
Opt("OnExitFunc", "_Close")
;OnAutoItExitRegister("_Close")

#NoTrayIcon

Global $DebugModeStyle
Global $DebugMode_Style            = 1
If $DebugMode_Style = 1 Then $DebugModeStyle = $WS_BORDER

Global $fSize[7] = [10, 11, 12, 13, 14, 28, 38], $ffTahoma = "Tahoma"
Global $fwNormal = 400, $fwBold = 800, $fsNormal = 0, $fsItalic = 2
Global $cRed   = 0xFF0000, $cBlue  = 0x0000FF, $cGrey   = 0xDADBDD, $cGreen     = 0x008000
Global $cWhite = 0xFFFFFF, $cBlack = 0x000000, $cYellow = 0xFFFF00, $cLightGrey = 0x808080

Global $GUIWidth     = @DesktopWidth, $GUIHeight = @DesktopHeight, $GUILeft = -1, $GUITop  = -1, $GUIbgColor = $cGrey, $GUIHeightCor = 0
Global $SectionWidth = $GUIWidth, $SectionHeight = $GUIHeight - 150

$hForm = GUICreate("Form", $GUIWidth, $GUIHeight, $GUILeft, $GUITop)
GUISetBkColor($GUIbgColor)

GUICtrlCreateLabel("F  O   R   M", 205, 5, $GUIWidth - 205, 65, BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle))
GUICtrlSetFont(-1, $fSize[6], $fwBold, $fsNormal, $ffTahoma)
GUICtrlSetColor(-1, $cBlue)

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

GUISetState(@SW_SHOW, $hForm)

_DateTable()

While 1
    $FormMsg = GUIGetMsg()

    If $FormMsg = $GUI_EVENT_CLOSE Then _Close()
WEnd

Func _DateTable()
    Local $sDatesList = @DesktopDir & "\DatesList.ini"

    $aPersonalList = IniReadSectionNames($sDatesList)

    Local $iDTHeadLeft = 0, $iDTHeadTop = 100, $iDTHeadWidth = $SectionWidth, $iDTHeadHeight = $SectionHeight, $GUIbgColor = $cGrey
    $hDTHead = GUICreate("Date Table Header", $iDTHeadWidth, $iDTHeadHeight, $iDTHeadLeft, $iDTHeadTop, $WS_CHILD, -1, $hForm)
    GUISetBkColor($GUIbgColor)

    Local $iHeadLeft = 5, $iHeadTop = 5, $iHeadWidth = 210, $iHeadHeighth = 105
    Local $iHeadStyle = BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle)
    GUICtrlCreateLabel("Имя", $iHeadLeft, $iHeadTop, $iHeadWidth, $iHeadHeighth, $iHeadStyle)
    GUICtrlSetBkColor(-1, $cRed)
    GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)
    GUICtrlCreateLabel("Дата", $iHeadLeft + 210, $iHeadTop, $iHeadWidth * 4 + 50, $iHeadHeighth, $iHeadStyle)
    GUICtrlSetBkColor(-1, $cBlue)
    GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)
	
	;test
	GUICtrlCreateLabel("Тест", $iHeadLeft + 210 + ($iHeadWidth * 4 + 50), $iHeadTop, $iHeadWidth * 4 + 50, $iHeadHeighth, $iHeadStyle)
    
	GUICtrlSetBkColor(-1, $cBlue)
    GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)
	
    Local $iDTBodyLeft = 0, $iDTBodyTop = 110, $iDTBodyWidth = $iDTHeadWidth, $iDTBodyHeight = $iDTHeadHeight - $iDTBodyTop, $GUIbgColor = $cGrey
    $hDTBody = GUICreate("Date Table Body", $iDTBodyWidth, $iDTBodyHeight, $iDTBodyLeft, $iDTBodyTop, $WS_CHILD + $WS_VSCROLL, -1, $hDTHead)
    GUISetBkColor($GUIbgColor)

    Local $iPLLeft = 5, $iPLTop = 0, $iPLWidth = 210, $iPLHeight = 30
    For $p = 1 To $aPersonalList[0]
        GUICtrlCreateLabel(" " & $aPersonalList[$p], $iPLLeft, $iPLTop, $iPLWidth, $iPLHeight, BitOr($SS_CENTERIMAGE, $DebugModeStyle))
        GUICtrlSetBkColor(-1, $cYellow)
        GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)

        $iDate = IniRead($sDatesList, $aPersonalList[$p], "Date", "NA")
        GUICtrlCreateLabel($iDate, $iPLLeft + 210, $iPLTop, $iPLWidth * 4 + 50, $iPLHeight, BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle))
        GUICtrlSetBkColor(-1, $cGreen)
        GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)

        $iPLTop += 30
    Next
	
    _GUIScrollBars_Init($hDTBody, 0, 0)
    _GUIScrollBars_Init($hDTHead, 0, 0)
	_GUIScrollBars_SetScrollInfoMax($hDTBody, 0, 0)
	_GUIScrollBars_SetScrollInfoMax($hDTBody, 1, Round($aPersonalList[0] * 1.84))
	_GUIScrollBars_SetScrollInfoMax($hDTHead, 0, $iPLWidth)
	_GUIScrollBars_SetScrollInfoMax($hDTHead, 1, 0)
	
    GUISetState(@SW_SHOW, $hDTHead)
    GUISetState(@SW_SHOW, $hDTBody)

    GUISetState(@SW_SHOW, $hForm)
EndFunc   ;==>_PPC

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)
    
    ; 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_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

Func _Close()
    Exit
EndFunc   ;==>_Close
 
Автор
X

XpycT

Скриптер
Сообщения
380
Репутация
133
CreatoR [?]
Нелогично. Как так можно перемещать кусок формы
grin.gif
Да и зачем?

Хочеться сделать как в Microsoft Excel когда ставиш "Закрепить Области"


Добавлено:
Сообщение автоматически объединено:

Я тут немного по "фантазировал" с вертикальной прокруткой и вот что получилось
Код:
#Region Includes
#include <ScrollBarConstants.au3>
#include <StructureConstants.au3>
#include <Array.au3>
#include <Date.au3>
#include <GuiScrollBars.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#EndRegion Includes
Opt("TrayIconDebug", 0)
OnAutoItExitRegister("_Close")
#NoTrayIcon

Global $DebugModeStyle
Global $DebugMode_Style            = 1
If $DebugMode_Style = 1 Then $DebugModeStyle = $WS_BORDER

Global $hDTList, $hDTBody

Global $fSize[7] = [10, 11, 12, 13, 14, 28, 38], $ffTahoma = "Tahoma"
Global $fwNormal = 400, $fwBold = 800, $fsNormal = 0, $fsItalic = 2
Global $cRed   = 0xFF0000, $cBlue  = 0x0000FF, $cGrey   = 0xDADBDD, $cGreen     = 0x008000
Global $cWhite = 0xFFFFFF, $cBlack = 0x000000, $cYellow = 0xFFFF00, $cLightGrey = 0x808080

Global $GUIWidth     = 1125, $GUIHeight = 830, $GUILeft = -1, $GUITop  = -1, $GUIbgColor = $cGrey, $GUIHeightCor = 0
Global $SectionWidth = $GUIWidth, $SectionHeight = $GUIHeight - 150

$hForm = GUICreate("Form", $GUIWidth, $GUIHeight, $GUILeft, $GUITop)
ConsoleWrite("$hForm = " & $hForm & @CR)
GUISetBkColor($GUIbgColor)

GUICtrlCreateLabel("F  O   R   M", 205, 5, $GUIWidth - 205, 65, BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle))
GUICtrlSetFont(-1, $fSize[6], $fwBold, $fsNormal, $ffTahoma)
GUICtrlSetColor(-1, $cBlue)

GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")

GUISetState(@SW_SHOW, $hForm)

_DateTable()

While 1
	$FormMsg = GUIGetMsg()

	If $FormMsg = $GUI_EVENT_CLOSE Then _Close()
WEnd

Func _DateTable()
	Local $sDatesList = @ScriptDir & "\DatesList.ini"

	$aPersonalList = IniReadSectionNames($sDatesList)

	Local $iDTBackLeft = 0, $iDTBackTop = 100, $iDTBackWidth = $SectionWidth, $iDTBackHeight = $SectionHeight, $GUIbgColor = 0xA6CAF0
	$hDTBack = GUICreate("Main Table", $iDTBackWidth, $iDTBackHeight, $iDTBackLeft, $iDTBackTop, $WS_CHILD, -1, $hForm)
	GUISetBkColor($GUIbgColor)

	Local $iDTNameLeft = 5, $iDTNameTop = 5, $iDTNameWidth = 210, $iDTNameHeight = 105, $GUIbgColor = $cRed
	$hDTName = GUICreate("Name Lable", $iDTNameWidth, $iDTNameHeight, $iDTNameLeft, $iDTNameTop, $WS_CHILD, -1, $hDTBack)
	GUISetBkColor($GUIbgColor)

	Local $iDTHeadLeft = 215, $iDTHeadTop = 5, $iDTHeadWidth = 890, $iDTHeadHeight = 105, $GUIbgColor = $cBlue
	$hDTHead = GUICreate("Header Part", $iDTHeadWidth, $iDTHeadHeight, $iDTHeadLeft, $iDTHeadTop, $WS_CHILD, -1, $hDTBack)
	GUISetBkColor($GUIbgColor)

	Local $iDTListLeft = 5, $iDTListTop = 110, $iDTListWidth = 210, $iDTListHeight = $iDTBackHeight - $iDTNameTop - $iDTNameHeight, $GUIbgColor = $cYellow
	$hDTList = GUICreate("Name List Part", $iDTListWidth, $iDTListHeight, $iDTListLeft, $iDTListTop, $WS_CHILD, -1, $hDTBack)
	ConsoleWrite("$hDTList = " & $hDTList & @CR)
	GUISetBkColor($GUIbgColor)
	Local $iPLLeft = 0, $iPLTop = 0, $iPLWidth = 210, $iPLHeight = 30
	For $p = 1 To $aPersonalList[0]
		GUICtrlCreateLabel($aPersonalList[$p], $iPLLeft, $iPLTop, $iPLWidth, $iPLHeight, BitOr($SS_CENTERIMAGE, $DebugModeStyle))
		GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)

		$iPLTop += 30
	Next

	Local $iDTBodyLeft = 215, $iDTBodyTop = 110, $iDTBodyWidth = 890, $iDTBodyHeight = $iDTBackHeight - $iDTNameTop - $iDTNameHeight, $GUIbgColor = $cGreen
	$hDTBody = GUICreate("Body Part", $iDTBodyWidth, $iDTBodyHeight, $iDTBodyLeft, $iDTBodyTop, $WS_CHILD + $WS_VSCROLL, -1, $hDTBack)
	ConsoleWrite("$hDTBody = " & $hDTBody & @CR)
	GUISetBkColor($GUIbgColor)

	Local $iPLLeft = 0, $iPLTop = 0, $iPLWidth = 210, $iPLHeight = 30
	For $p = 1 To $aPersonalList[0]
		$iDate = IniRead($sDatesList, $aPersonalList[$p], "Date", "NA")
		GUICtrlCreateLabel($iDate, $iPLLeft, $iPLTop, $iPLWidth * 4 + 30, $iPLHeight, BitOr($SS_CENTER, $SS_CENTERIMAGE, $DebugModeStyle))
		GUICtrlSetFont(-1, $fSize[0], $fwBold, $fsNormal, $ffTahoma)

		$iPLTop += 30
	Next

; 	_GUIScrollBars_Init($hDTList, -1, Round($aPersonalList[0] * 1.84))
	_GUIScrollBars_Init($hDTBody, -1, Round($aPersonalList[0] * 1.84))

	GUISetState(@SW_SHOW, $hDTBack)
	GUISetState(@SW_SHOW, $hDTName)
	GUISetState(@SW_SHOW, $hDTHead)
	GUISetState(@SW_SHOW, $hDTList)
	GUISetState(@SW_SHOW, $hDTBody)

	GUISetState(@SW_SHOW, $hForm)
EndFunc   ;==>_PPC

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)

	; 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)

	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

; 	$hWnd = $hDTList
; 	ConsoleWrite("$hWnd = " & $hWnd & @CR)
	; Get all the vertial scroll bar information
	Local $tSCROLLINFO_List = _GUIScrollBars_GetScrollInfoEx($hDTList, $SB_VERT)
	$Min_List = DllStructGetData($tSCROLLINFO_List, "nMin")
	$Max_List = DllStructGetData($tSCROLLINFO_List, "nMax")
	$Page_List = DllStructGetData($tSCROLLINFO_List, "nPage")
	; Save the position for comparison later on
	$yPos_List = DllStructGetData($tSCROLLINFO_List, "nPos")
	$Pos_List = $yPos_List
	$TrackPos_List = DllStructGetData($tSCROLLINFO_List, "nTrackPos")

	Local $tSCROLLINFO_Body = _GUIScrollBars_GetScrollInfoEx($hDTBody, $SB_VERT)
	$Min_Body = DllStructGetData($tSCROLLINFO_Body, "nMin")
	$Max_Body = DllStructGetData($tSCROLLINFO_Body, "nMax")
	$Page_Body = DllStructGetData($tSCROLLINFO_Body, "nPage")
	; Save the position for comparison later on
	$yPos_Body = DllStructGetData($tSCROLLINFO_Body, "nPos")
	$Pos_Body = $yPos_Body
	$TrackPos_Body = DllStructGetData($tSCROLLINFO_Body, "nTrackPos")

	Switch $nScrollCode
		Case $SB_TOP; user clicked the HOME keyboard key
			DllStructSetData($tSCROLLINFO_List, "nPos", $Min_List)
			DllStructSetData($tSCROLLINFO_Body, "nPos", $Min_Body)

		Case $SB_BOTTOM; user clicked the END keyboard key
			DllStructSetData($tSCROLLINFO_List, "nPos", $Max_List)
			DllStructSetData($tSCROLLINFO_Body, "nPos", $Max_Body)

		Case $SB_LINEUP; user clicked the top arrow
			DllStructSetData($tSCROLLINFO_List, "nPos", $Pos_List - 1)
			DllStructSetData($tSCROLLINFO_Body, "nPos", $Pos_Body - 1)

		Case $SB_LINEDOWN; user clicked the bottom arrow
			DllStructSetData($tSCROLLINFO_List, "nPos", $Pos_List + 1)
			DllStructSetData($tSCROLLINFO_Body, "nPos", $Pos_Body + 1)

		Case $SB_PAGEUP; user clicked the scroll bar shaft above the scroll box
			DllStructSetData($tSCROLLINFO_List, "nPos", $Pos_List - $Page_List)
			DllStructSetData($tSCROLLINFO_Body, "nPos", $Pos_Body - $Page_Body)

		Case $SB_PAGEDOWN; user clicked the scroll bar shaft below the scroll box
			DllStructSetData($tSCROLLINFO_List, "nPos", $Pos_List + $Page_List)
			DllStructSetData($tSCROLLINFO_Body, "nPos", $Pos_Body + $Page_Body)

		Case $SB_THUMBTRACK; user dragged the scroll box
			DllStructSetData($tSCROLLINFO_List, "nPos", $TrackPos_List)
			DllStructSetData($tSCROLLINFO_Body, "nPos", $TrackPos_Body)
	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_List, "fMask", $SIF_POS)
	_GUIScrollBars_SetScrollInfo ($hDTList, $SB_VERT, $tSCROLLINFO_List)
	_GUIScrollBars_GetScrollInfo ($hDTList, $SB_VERT, $tSCROLLINFO_List)
	;// If the position has changed, scroll the window and update it
	$Pos_List = DllStructGetData($tSCROLLINFO_List, "nPos")

	If ($Pos_List <> $yPos_List) Then
		_GUIScrollBars_ScrollWindow ($hDTList, 0, $yChar * ($yPos_List - $Pos_List))
		$yPos_List = $Pos_List
	EndIf

	DllStructSetData($tSCROLLINFO_Body, "fMask", $SIF_POS)
	_GUIScrollBars_SetScrollInfo ($hDTBody, $SB_VERT, $tSCROLLINFO_Body)
	_GUIScrollBars_GetScrollInfo ($hDTBody, $SB_VERT, $tSCROLLINFO_Body)
	;// If the position has changed, scroll the window and update it
	$Pos_Body = DllStructGetData($tSCROLLINFO_Body, "nPos")

	If ($Pos_Body <> $yPos_Body) Then
		_GUIScrollBars_ScrollWindow ($hDTBody, 0, $yChar * ($yPos_Body - $Pos_Body))
		$yPos_Body = $Pos_Body
	EndIf

	Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_VSCROLL

Func _Close()
	Exit
EndFunc   ;==>_Close
 
Верх