窗口垂直滚动条显示问题,窗口尺寸改变后就不显示了,怎么回事呢(已解决)
本帖最后由 qsy666888 于 2018-6-24 22:50 编辑窗口垂直滚动条显示问题,窗口尺寸改变后就不显示了,怎么回事呢?
还有数目增加后,拉动滚动条显示不完
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
Global$p =35
_Main()
Func _Main()
Local $nFileMenu,$nExititem, $GUIMsg,$Form1,$h_cGUI
$Form1 = GUICreate("Form1", 543, 661, -1, -1)
GUISetBkColor(0x88AABB)
$h_cGUI = GUICreate("Child GUI", 500, 600, 30, 20, $WS_CHILD, $WS_EX_CLIENTEDGE, $Form1);如果300改为500或者600的时候,就不显示了
$k = 5
For $i = 1 To $p
Global $Label[$i+1]
$Label[$i] = GUICtrlCreateLabel("Label"&$i, 160, $k, 244, 24)
GUICtrlSetBkColor(-1, 0xEEC591)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808000)
$k += 30
Next
GUISetBkColor(0X006400)
GUISetState()
GUICtrlSetResizing($h_cGUI, $GUI_DOCKALL)
GUISwitch($Form1)
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
_GUIScrollBars_Init($h_cGUI)
GUISetState()
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg
Case -3
Exit
EndSwitch
WEnd
EndFunc
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($__g_aSB_WindowInfo) - 1
If $__g_aSB_WindowInfo[$x] = $hWnd Then
$index = $x
$yChar = $__g_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 ; 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 ; 用户单击滚动框下方的滚动条轴
DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
Case $SB_THUMBTRACK ; user dragged the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
EndSwitch
;~ // 设置位置,然后检索它。由于调整
;~ // 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)
;// 如果位置已经改变,请滚动窗口并更新它
$Pos = DllStructGetData($tSCROLLINFO, "nPos")
If ($Pos <> $yPos) Then
_GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
$yPos = $Pos
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_VSCROLL
_GUIScrollBars_Init($h_cGUI)
_GUIScrollBars_SetScrollRange($h_cGUI, $SB_VERT, 0, 220 * 0.30) ;设置垂直滚动条参数 chzj589 发表于 2018-6-25 12:19
_GUIScrollBars_Init($h_cGUI)
_GUIScrollBars_SetScrollRange($h_cGUI, $SB_VERT, 0, 220 * 0.30) ;设 ...
感谢感谢,大佬,
页:
[1]