[已解决]请教如何滚动窗口显示更多控件
本帖最后由 kxing 于 2011-5-5 18:30 编辑我希望在一个窗口内显示多个input输入框。
但是窗口高度远远不够。因此需要滚动显示。
麻烦高手帮忙,多谢!
我加入了垂直滚动样式但也无法实现。。。
#include <WindowsConstants.au3>
guicreate("hello",300,200,-1,-1,bitor($WS_VSCROLL,$WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_SYSMENU))
guisetbkcolor(0x000000)
guisetstate()
$height=5
for $i=1 to 100
guictrlcreateinput($i,10,$height,280,20)
$height+=25
next
do
until guigetmsg()=-3 并没有这么简单吧!
#include <GUIScrollBars.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollBarConstants.au3>
$hGUI = GUICreate('', 400, 300, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
_GUIScrollBars_Init($hGUI)
_GUIScrollBars_SetScrollRange($hGUI, $SB_VERT, 10, 170)
Global $z = 5
For $i = 1 To 100
GUICtrlCreateInput($i, 10, $z, 300, 20)
$z += 25
Next
GUISetState()
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
Do
Until GUIGetMsg() = -3
Func WM_VSCROLL($hWnd, $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] = $hWnd Then
$index = $x
$yChar = $aSB_WindowInfo[$index]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
$Min = DllStructGetData($tSCROLLINFO, "nMin")
$Max = DllStructGetData($tSCROLLINFO, "nMax")
$Page = DllStructGetData($tSCROLLINFO, "nPage")
$yPos = DllStructGetData($tSCROLLINFO, "nPos")
$Pos = $yPos
$TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
Switch $nScrollCode
Case $SB_TOP
DllStructSetData($tSCROLLINFO, "nPos", $Min)
Case $SB_BOTTOM
DllStructSetData($tSCROLLINFO, "nPos", $Max)
Case $SB_LINEUP
DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
Case $SB_LINEDOWN
DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
Case $SB_PAGEUP
DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
Case $SB_PAGEDOWN
DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
Case $SB_THUMBTRACK
DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
EndSwitch
DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
_GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
$Pos = DllStructGetData($tSCROLLINFO, "nPos")
If ($Pos <> $yPos) Then
_GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
$yPos = $Pos
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_VSCROLL 嘿嘿,多谢水木子老兄!!!!
不过有一点是当用tab切到未显示的控件上时不会自动下移,有点遗憾。。。
页:
[1]