成都网站建设设计

将想法与焦点和您一起共享

关于vbnet滚轮事件的信息

VB.NET picturebox 内绘图完图形放大缩小移动 鼠标控制 。比较笨看了VB的代码不明白 求解

。net 不用api就行

10多年的杂多网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整杂多建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“杂多网站设计”,“杂多网站推广”以来,每个客户项目都认真落实执行。

缩放操作

Function 缩放(ByVal bitmap As Bitmap, ByVal 倍数 As Single) As Bitmap

Dim w As Integer = bitmap.Width * 倍数

Dim h As Integer = bitmap.Height * 倍数

Dim tem As New Bitmap(w, h)

Dim g As Graphics = Graphics.FromImage(tem)

g.DrawImage(bitmap, New Rectangle(0, 0, w, h), New Rectangle(0, 0, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel)

g.Dispose()

Return tem

End Function

鼠标滚轮事件 MouseWheel

MouseEventArgs.Delta 值可以判断滚动方向

VB 鼠标滚轮事件在哪?

在VB中,并没有包含鼠标滚轮的滚动事件,所以必须用API自己捕获滚动信息并加以处理。主要需要用到CallWindowProc和SetWindowLong两个函数,请参考以下代码:

’在模块中

‘声明方法

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

Public Const GWL_WNDPROC = (-4)

Public Const WM_MOUSEWHEEL = H20A

Public PrevWndProc As Long

Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long ‘写自己处理鼠标滚动的事件,这里让Form上下滚动

Dim t(0 To 1) As Integer

If uMsg = WM_MOUSEWHEEL Then

If wParam 0 Then 'backward

Form1.Top = Form1.Top + 10

Else 'forforward

Form1.Top = Form1.Top - 10

End If

Else

WndProc = CallWindowProc(PrevWndProc, hwnd, uMsg, wParam, lParam) ‘让Windows处理其他事件

End If

End Function

然后在Form中写入:

Option Explicit

Private Sub Form_Load()

PrevWndProc = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf WndProc) ‘让WndProc来处理该窗体的事件

End Sub

Private Sub Form_Unload(Cancel As Integer)

Dim lResult As Long

lResult = SetWindowLong(Me.hwnd, GWL_WNDPROC, PrevWndProc) ‘让Windows默认的函数来处理事件

End Sub

关于CallWindowProc和SetWindowLong您可以参考以下文章:

SetWindowLong

CallWindowProc

vb.net中怎么才能模拟鼠标滚轮移动

1、滚动条分为水平滚动条(HSCROLLBAR)和垂直滚动条(VSCROLLBAR)两种,可以作为输入设备或者速度、数量的指示器来使用. 2、基本属性:object.max[=value],object.min[=value],最大最小范围 object.value[=value],

vb.net 禁用第三方 控件滚轮事件

拦截窗口程序消息可以解决

参考 VB王国荣API讲座 讲消息的那章

几个API就可以搞定

vb.net panel的vscroll的滑轮事件

点击panel时得到panel的焦点,就可以用鼠标滚轮来控制滚动条了!代码如下:

Private Sub Panel1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel1.Click

Panel1.Focus()

End Sub

VB怎么实现滚动条对鼠标中轴的响应啊?

VB可以使用子类化处理鼠标滚轮消息。

新建工程

在窗体中添加滚动条VScroll1

'窗体代码

Private Sub Form_Load()

'取得控件的句柄

hwndVS = VScroll1.hwnd

'保存smMap控件的默认窗口消息处理函数地址

OldWindowProc = GetWindowLong(VScroll1.hwnd, GWL_WNDPROC)

'将smMap控件的消息处理函数指定为自定义函数NewWindowProc

Call SetWindowLong(VScroll1.hwnd, GWL_WNDPROC, AddressOf NewWindowProc)

End Sub

添加一模块:

Option Explicit

Public 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

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Const GWL_WNDPROC = -4

Public Const WM_MOUSEWHEEL = H20A

Public OldWindowProc As Long '用来保存系统默认的窗口消息处理函数的地址

Public hwndVS As Long '用来保存控件的句柄

'自定义的消息处理函数

Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

On Error Resume Next

If msg = WM_MOUSEWHEEL Then

'则对鼠标滚轮事件进行处理

If wParam = -7864320 Then '向下滚动

Form1.VScroll1.Value = Form1.VScroll1.Value + 1

ElseIf wParam = 7864320 Then '向上滚动

Form1.VScroll1.Value = Form1.VScroll1.Value - 1

End If

Else

'调用默认窗口消息处理函数

NewWindowProc = CallWindowProc(OldWindowProc, hwnd, msg, wParam, lParam)

End If

End Function


当前题目:关于vbnet滚轮事件的信息
网页地址:http://chengdu.cdxwcx.cn/article/dodhssd.html