|
-
Nov 26th, 2008, 10:06 PM
#1
Thread Starter
Addicted Member
Mouse Wheel and Form Opacity
hello, i am wanting to be able to change the form's opacity up and down whenever the mouse wheel is scrolled, but only to a point. how can i do this? ^^
-
Nov 27th, 2008, 05:01 AM
#2
Re: Mouse Wheel and Form Opacity
For mouse wheel events see this
for opacity, declare these API's
vb Code:
Option Explicit
Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2&
Private Function Opacity(Value As Byte, Frm As Form)
On Error GoTo ErrorHandler
Dim MaxVal As Byte, MinVal As Byte
'20 is the lowest opacity setting and 255 is the highest
MinVal = 20: MaxVal = 255
If Value > MaxVal Then Value = MaxVal
If Value < MinVal Then Value = MinVal
SetWindowLongA Frm.hwnd, GWL_EXSTYLE, GetWindowLongA(Frm.hwnd, GWL_EXSTYLE) _
Or WS_EX_LAYERED
SetLayeredWindowAttributes Frm.hwnd, 0, Value, LWA_ALPHA
ErrorHandler: Exit Function
End Function
Public Sub MouseWheelRolled()
'to use this event see
'http://www.andreavb.com/tip060008.html as mentioned in the 1st line above
'This will change the form "me"'s opacity to 150.
Opacity 150, Me
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Nov 27th, 2008, 10:34 AM
#3
Lively Member
Re: Mouse Wheel and Form Opacity
Sorry to barge in on this but how would you use mouse wheel with Browser control, or FireFox Browser control.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|