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

VB6满足滚动条和鼠标滚轮事件的两个工程,用同样的模块,一个正常,一个就不正常,问题出在什么地方?请哪位高手指点一下:
同样的一个模块代码(原代码在附件中)
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
If WHEEL_SCROLL_LINES > form2.VScroll1.max Then
WHEEL_SCROLL_LINES = form2.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 - 100 Then
Form1.VScroll1.Value = Form1.VScroll1.Value + 100
Else
Form1.VScroll1.Value = Form1.VScroll1.max
End If
If form2.VScroll1.Value <= form2.VScroll1.max - 100 Then
form2.VScroll1.Value = form2.VScroll1.Value + 100
Else
form2.VScroll1.Value = form2.VScroll1.max
End If

ElseIf wParam = 7864320 Then
If Form1.VScroll1.Value >= 100 Then
Form1.VScroll1.Value = Form1.VScroll1.Value - 100
Else
Form1.VScroll1.Value = 0
End If
If form2.VScroll1.Value >= 100 Then
form2.VScroll1.Value = form2.VScroll1.Value - 100
Else
form2.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
hhFiommk.rar (19.52 KB) [求助]问题出在什么地方?


搜索更多相关主题的帖子: 工程 
2006-11-01 21:15
bestfeng
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:179
专家分:0
注 册:2006-10-31
收藏
得分:0 
可以滚动,不太清楚你要滚动什么 dd,要滚动窗体?要是滚动窗体的话,你要有一定的错误处理机制,这个代码在窗体超出边界继续滚动就会出错。
2006-11-02 08:27
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 

问题在"不正常"的工程上,它的第一个窗体是"悬浮窗体"与第二个窗体同时打开,而第二个窗体从最大化缩小后,滚动条就出不来了(不正常之处).
而"正常"的工程,不论哪个窗体缩小后,水平和垂直滚动条都会出来.
两个工程用的是同一个模块.
如何将"不正常"工程中第二个窗体的滚动条显示出来?

2006-11-02 12:35
快速回复:[求助]问题出在什么地方?
数据加载中...
 
   



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

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