Results 1 to 3 of 3

Thread: Mouse Wheel and Form Opacity

  1. #1

    Thread Starter
    Addicted Member clownboy's Avatar
    Join Date
    Aug 2008
    Location
    Wellington, NZ
    Posts
    137

    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? ^^

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Mouse Wheel and Form Opacity

    For mouse wheel events see this

    for opacity, declare these API's

    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetWindowLongA Lib "user32" _
    4. (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    5.  
    6. Private Declare Function SetWindowLongA Lib "user32" _
    7. (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    8.  
    9. Private Declare Function SetLayeredWindowAttributes Lib "user32" _
    10. (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, _
    11. ByVal dwFlags As Long) As Long
    12.  
    13. Private Const GWL_EXSTYLE = (-20)
    14.  
    15. Private Const WS_EX_LAYERED = &H80000
    16.  
    17. Private Const LWA_ALPHA = &H2&
    18.  
    19. Private Function Opacity(Value As Byte, Frm As Form)
    20.  
    21.     On Error GoTo ErrorHandler
    22.  
    23.     Dim MaxVal As Byte, MinVal As Byte
    24.    
    25.     '20 is the lowest opacity setting and 255 is the highest
    26.     MinVal = 20: MaxVal = 255
    27.  
    28.     If Value > MaxVal Then Value = MaxVal
    29.  
    30.     If Value < MinVal Then Value = MinVal
    31.  
    32.     SetWindowLongA Frm.hwnd, GWL_EXSTYLE, GetWindowLongA(Frm.hwnd, GWL_EXSTYLE) _
    33.     Or WS_EX_LAYERED
    34.  
    35.     SetLayeredWindowAttributes Frm.hwnd, 0, Value, LWA_ALPHA
    36.  
    37. ErrorHandler:     Exit Function
    38.  
    39. End Function
    40.  
    41. Public Sub MouseWheelRolled()
    42.     'to use this event see
    43.     'http://www.andreavb.com/tip060008.html as mentioned in the 1st line above
    44.    
    45.  'This will change the form "me"'s opacity to 150.
    46.     Opacity 150, Me
    47. 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

  3. #3
    Lively Member
    Join Date
    Nov 2008
    Posts
    67

    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
  •  



Click Here to Expand Forum to Full Width