| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1819 人关注过本帖
标题:[求助]滚动条闪烁如何解决?急盼!
只看楼主 加入收藏
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
结帖率:94.12%
收藏
 问题点数:0 回复次数:4 
[求助]滚动条闪烁如何解决?急盼!

下面一段是VB支持鼠标滚轮程序代码,现在的问题是:滚动条会闪烁,怎样消除?请高手指点,急盼!

模块:
Option Explicit

Public Type POINTL
x As Long
y As Long
End Type
Declare Function CallWindowProc _
Lib "USER32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Declare Function SetWindowLong _
Lib "USER32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Declare Function SystemParametersInfo _
Lib "USER32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
lpvParam As Any, _
ByVal fuWinIni As Long) As Long

Declare Function ScreenToClient Lib "USER32" _
(ByVal hWnd As Long, xyPoint As POINTL) As Long

Public Const GWL_WNDPROC = -4
Public Const SPI_GETWHEELSCROLLLINES = 104
Public Const WM_MOUSEWHEEL = &H20A
Public WHEEL_SCROLL_LINES As Long

Global lpPrevWndProc As Long

Public Sub Hook(ByVal hWnd As Long)
lpPrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
Call SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, WHEEL_SCROLL_LINES, 0)
If WHEEL_SCROLL_LINES > Form1.VScroll1.Max Then
WHEEL_SCROLL_LINES = Form1.VScroll1.Max
End If
End Sub

Public Sub UnHook(ByVal hWnd As Long)
Dim lngReturnValue As Long
lngReturnValue = SetWindowLong(hWnd, GWL_WNDPROC, lpPrevWndProc)
End Sub

Function WindowProc(ByVal hw As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim pt As POINTL
Select Case uMsg
Case WM_MOUSEWHEEL
If wParam = -7864320 Then
If Form1.VScroll1.Value <= Form1.VScroll1.Max - 10 Then
Form1.VScroll1.Value = Form1.VScroll1.Value + 10
Else
Form1.VScroll1.Value = Form1.VScroll1.Max
End If
ElseIf wParam = 7864320 Then
If Form1.VScroll1.Value >= 10 Then
Form1.VScroll1.Value = Form1.VScroll1.Value - 10
Else
Form1.VScroll1.Value = 0
End If
End If
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Select
End Function

Public Function HIWORD(LongIn As Long) As Integer
HIWORD = (LongIn And &HFFFF0000) \ &H10000
End Function

Public Function LOWORD(LongIn As Long) As Integer
LOWORD = LongIn And &HFFFF&
End Function


程序:
Private Sub Form_Load()
Hook Me.hWnd
End Sub

Private Sub Form_Resize()
If Frame1.Height > Me.Height Then
VScroll1.Visible = True
Else
VScroll1.Visible = False
End If
If Frame1.Width > Me.Width Then
HScroll1.Visible = True
Else
HScroll1.Visible = False
End If
HScroll1.Left = 0
HScroll1.Top = Me.ScaleHeight - HScroll1.Height
VScroll1.Left = Me.ScaleWidth - VScroll1.Width
VScroll1.Top = 0
HScroll1.Width = Me.ScaleWidth
VScroll1.Height = Me.ScaleHeight
If VScroll1.Visible = True Then
If HScroll1.Visible = True Then
HScroll1.Width = Abs(Me.ScaleWidth - VScroll1.Width)
      VScroll1.Height = Abs(Me.ScaleHeight - HScroll1.Height)
End If
End If
HScroll1.Max = (Frame1.Width - Me.Width) + 3 * VScroll1.Width
VScroll1.Max = (Frame1.Height - Me.Height) + 3 * HScroll1.Height
HScroll1.ZOrder
VScroll1.ZOrder

End Sub

Private Sub Form_Unload(Cancel As Integer)
UnHook Me.hWnd
End Sub

Private Sub HScroll1_Change()
Frame1.Left = -HScroll1.Value

End Sub

Private Sub VScroll1_Change()
Frame1.Top = -VScroll1.Value
End Sub
搜索更多相关主题的帖子: Long 鼠标 ByVal 滚动 闪烁 
2006-10-15 21:24
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 
怎么没人回答?
上面工程的窗体高height=11250;Frame1的窗体高height=1800;(多个图片单屏放不下,所以引用了框架和滚动条)
窗体宽width=15360;Frame1的width=15085
上面的设置有问题吗?
2006-10-16 08:48
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 
上面的代码很奇怪,在有的机子上不会闪烁,有的机子就会闪烁。
难道是VB6版本问题?还是其它的问题?偶用的VB6企业版,注册码111-1111111分辨率是1024*768
请哪位大侠帮帮忙!提供点线索。
2006-10-16 19:02
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 
这个问题已经解决了,即将scrollbar的tabstop设置为false即可.
2006-10-19 21:16
afeibfp
Rank: 2
等 级:论坛游民
威 望:1
帖 子:11
专家分:31
注 册:2007-6-1
收藏
得分:0 
8年后的谢谢
2014-06-05 04:37
快速回复:[求助]滚动条闪烁如何解决?急盼!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026476 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved