VB可以使用子類化處理鼠標(biāo)滾輪消息。
創(chuàng)新互聯(lián)成立于2013年,我們提供高端重慶網(wǎng)站建設(shè)公司、成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)站定制、網(wǎng)絡(luò)營銷推廣、小程序制作、微信公眾號(hào)開發(fā)、成都網(wǎng)站營銷服務(wù),提供專業(yè)營銷思路、內(nèi)容策劃、視覺設(shè)計(jì)、程序開發(fā)來完成項(xiàng)目落地,為混凝土攪拌罐企業(yè)提供源源不斷的流量和訂單咨詢。
新建工程
在窗體中添加滾動(dòng)條VScroll1
'窗體代碼
Private Sub Form_Load()
'取得控件的句柄
hwndVS = VScroll1.hwnd
'保存smMap控件的默認(rèn)窗口消息處理函數(shù)地址
OldWindowProc = GetWindowLong(VScroll1.hwnd, GWL_WNDPROC)
'將smMap控件的消息處理函數(shù)指定為自定義函數(shù)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 '用來保存系統(tǒng)默認(rèn)的窗口消息處理函數(shù)的地址
Public hwndVS As Long '用來保存控件的句柄
'自定義的消息處理函數(shù)
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
'則對(duì)鼠標(biāo)滾輪事件進(jìn)行處理
If wParam = -7864320 Then '向下滾動(dòng)
Form1.VScroll1.Value = Form1.VScroll1.Value + 1
ElseIf wParam = 7864320 Then '向上滾動(dòng)
Form1.VScroll1.Value = Form1.VScroll1.Value - 1
End If
Else
'調(diào)用默認(rèn)窗口消息處理函數(shù)
NewWindowProc = CallWindowProc(OldWindowProc, hwnd, msg, wParam, lParam)
End If
End Function
根據(jù)我的經(jīng)驗(yàn),應(yīng)該是PICtureBox沒有獲取焦點(diǎn),而win10下不知道什么原因能自動(dòng)獲取焦點(diǎn),所以湊巧成功了,因此你應(yīng)該讓圖形框獲取焦點(diǎn)
如:picturebox1.focus()
不知道是不是解決了你的問題
。net 不用api就行
縮放操作
Function 縮放(ByVal bitmap As Bitmap, ByVal 倍數(shù) As Single) As Bitmap
Dim w As Integer = bitmap.Width * 倍數(shù)
Dim h As Integer = bitmap.Height * 倍數(shù)
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
鼠標(biāo)滾輪事件 MouseWheel
MouseEventArgs.Delta 值可以判斷滾動(dòng)方向
1、滾動(dòng)條分為水平滾動(dòng)條(HSCROLLBAR)和垂直滾動(dòng)條(VSCROLLBAR)兩種,可以作為輸入設(shè)備或者速度、數(shù)量的指示器來使用. 2、基本屬性:object.max[=value],object.min[=value],最大最小范圍 object.value[=value],
本文名稱:vb點(diǎn)虐
鼠標(biāo)滾輪 vb6鼠標(biāo)滾輪事件
本文地址:http://redsoil1982.com.cn/article28/ddiedjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、定制開發(fā)、軟件開發(fā)、域名注冊
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)