INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: MouseOver VB6 Code Sample  (Read 14150 times)

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20048
MouseOver VB6 Code Sample
« on: February 07, 2006, 12:46:02 pm »

I learned Something Today Since I Have Been Playing With Voice (TextAloud) Program And Make Small Mp3 Files For Command buttons "Back", "Next" etc...

Trying To Figure Out How To Detect When The Mouse Was Over The Command button. Where The MouseMove Would Normally Only Detect Once You Move The Mouse Away From The Button. This Sample Works Perfectly

Declare
Quote
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCapture Lib "user32" () As Long

To Detect That A Mouse Is Over A Command Button In This Case "Back(0)"

Quote
Private Sub Back_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (X < 0) Or (Y < 0) Or (X > Back(0).Width) Or (Y > Back(0).Height) Then
        ReleaseCapture             ' the mouse is no longer over the button
    ElseIf GetCapture() <> Back(0).hwnd Then
        SetCapture Back(0).hwnd   ' the mouse is over the button
        PlayMediaFile Back(0).Caption
    End If
End Sub

Play A Sound Using The Media Player

Quote
Private Sub PlayMediaFile(MP3FileName As String)
    On Error Resume Next
    WindowsMediaPlayer1.URL = App.Path & "\Mp3\" & MP3FileName & ".mp3"
End Sub
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio
https://MyAAGrapevines.com
Fayetteville, NC, USA

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: MouseOver VB6 Code Sample
« Reply #1 on: February 07, 2006, 04:22:17 pm »

Always good to know these things :)
Pages: [1]   Go Up