tcpuuu 发表于 2012-3-4 17:48:38

求助 水平滚动条的窗口. 怎麼滾?

滾到 黃色 全部看見 該怎麼滾
右上要有最小化 和 關閉
===========================#include <WindowsConstants.au3>
GUICreate("XXXX",200,100,-1,-1,$WS_HSCROLL)
;--------------------------------------
$Input1 = GUICtrlCreateLabel("",100,8,500,20)
GUICtrlSetBkColor(-1,0xFFFF00)
GUISetState()
While 1
      $msg = GUIGetMsg()
      Switch $msg
                Case -3
                        Exit         
      EndSwitch
WEnd===================================================

afan 发表于 2012-3-4 21:22:33

GUIRegisterMsg() 以下消息
$WM_SIZE, $WM_VSCROLL, $WM_HSCROLL
再在消息里处理,自己研究吧。

298311657 发表于 2012-3-4 21:42:32


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
$hGUI = GUICreate("XXXX",200,100,-1,-1)
;--------------------------------------
$Input1 = GUICtrlCreateLabel("",100,8,500,20)
GUICtrlSetBkColor(-1,0xFFFF00)
GUISetState()
_GUIScrollBars_Init($hGUI)
GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")
While 1
      $msg = GUIGetMsg()
      Switch $msg
                Case -3
                        Exit         
      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] = $hWnd Then
                        $index = $x
                        $xChar = $aSB_WindowInfo[$index]
                        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

298311657 发表于 2012-3-4 21:42:44

帮助文档抄的
页: [1]
查看完整版本: 求助 水平滚动条的窗口. 怎麼滾?