Click here to Skip to main content
16,008,075 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionChecklistbox in Datagrid Pin
neha.lad10-Jan-09 18:21
neha.lad10-Jan-09 18:21 
AnswerRe: Checklistbox in Datagrid Pin
Reza Raad10-Jan-09 19:44
Reza Raad10-Jan-09 19:44 
AnswerRe: Checklistbox in Datagrid Pin
Anubhava Dimri11-Jan-09 20:43
Anubhava Dimri11-Jan-09 20:43 
QuestionRecording a song played in program Pin
Gagan.2010-Jan-09 17:20
Gagan.2010-Jan-09 17:20 
AnswerRe: Recording a song played in program Pin
Christian Graus11-Jan-09 5:00
protectorChristian Graus11-Jan-09 5:00 
AnswerRe: Recording a song played in program Pin
Anubhava Dimri11-Jan-09 20:48
Anubhava Dimri11-Jan-09 20:48 
GeneralRe: Recording a song played in program Pin
Gagan.2011-Jan-09 22:22
Gagan.2011-Jan-09 22:22 
QuestionMouse Hook Pin
Zaegra10-Jan-09 3:24
Zaegra10-Jan-09 3:24 
Hey,
I got the following code for a Mouse Hook
(http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/3d06022f5a2f804?hl=en&ie=UTF-8&oe=UTF8&q=visualcore.com+hook#448617bc134d8a27)



Imports System.Runtime.InteropServices
Imports System.Reflection
Imports System.Drawing
Imports System.Threading
Imports TestMouseHook

Public Class Class1

    Private f As New Form1()

    Public Structure POINTAPI
        Public x As Long
        Public y As Long
    End Structure

    Public Structure MSLLHOOKSTRUCT
        Public pt As POINTAPI
        Public MouseData As Long
        Public Flags As Long
        Public Time As Long
        Public dwExtraInfo As Long
    End Structure

     Constants
    Public Const WM_RBUTTONDOWN = H204
    Public Const WM_RBUTTONUP = H205
    Private Const WH_MOUSE_LL = 14          Hook Flag
    Private Const HC_ACTION = 0

    Public mHandle As Integer

    Public Declare Function UnhookWindowsHookEx Lib "user32" _
     (ByVal hHook As Integer) As Integer

    Public Declare Function SetWindowsHookEx Lib "user32" _
      Alias "SetWindowsHookExA" (ByVal idHook As Integer, _
      ByVal lpfn As MouseHookDelegate, ByVal hmod As Integer, _
      ByVal dwThreadId As Integer) As Integer

    Private Declare Function GetAsyncKeyState Lib "user32" _
      (ByVal vKey As Integer) As Integer

    Private Declare Function CallNextHookEx Lib "user32" _
      (ByVal hHook As Integer, _
      ByVal nCode As Integer, _
      ByVal wParam As Integer, _
      ByVal lParam As MSLLHOOKSTRUCT) As Integer

    Public Function MouseCallback(ByVal Code As Integer, _
      ByVal wParam As Integer, _
      ByRef lParam As MSLLHOOKSTRUCT) As Integer

        If (Code = HC_ACTION) Then
            Debug.WriteLine(wParam.ToString())
            Select Case wParam
                Case WM_RBUTTONDOWN, WM_RBUTTONUP
                    Debug.WriteLine(wParam.ToString())
                    Return 1
            End Select
        End If

        Return CallNextHookEx(mHandle, _
          Code, wParam, lParam)
    End Function

    Public Delegate Function MouseHookDelegate( _
      ByVal Code As Integer, _
      ByVal wParam As Integer, ByRef lParam As MSLLHOOKSTRUCT) _
                   As Integer

    <marshalas(unmanagedtype.functionptr)> _
    Private callback As MouseHookDelegate

    Public Sub HookMouse(ByRef ff As Form)
        f = ff
        callback = New MouseHookDelegate(AddressOf MouseCallback)

        mHandle = SetWindowsHookEx( _
          WH_MOUSE_LL, callback, _
          Marshal.GetHINSTANCE( _
          Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
    End Sub

    Public Sub UnHookMouse()
        Call UnhookWindowsHookEx(mHandle)
    End Sub

End Class 

I created a Class called Class1, just as in the example.

When I execute the following code the hook is actually set, but when I click outside my application the click isn't registered.

Dim MouseHook as New Class1
MouseHook.HookMouse(Me)


I think that this is happening because there is no event for an "outside application click". Now my question is: How can I make an event that is fired when the mouse is clicked outside my application using the functions declared in the class? I never "made" an event before, if it's even possible Wink | ;)

I was hoping you guys could help me out Wink | ;) Smile | :)

All help is appreciated,
--Zaegra--
QuestionMonitor System Pin
Anubhava Dimri10-Jan-09 0:13
Anubhava Dimri10-Jan-09 0:13 
AnswerRe: Monitor System Pin
Eddy Vluggen10-Jan-09 0:57
professionalEddy Vluggen10-Jan-09 0:57 
AnswerRe: Monitor System Pin
Dave Kreskowiak10-Jan-09 2:54
mveDave Kreskowiak10-Jan-09 2:54 
GeneralRe: Monitor System Pin
Luc Pattyn10-Jan-09 3:49
sitebuilderLuc Pattyn10-Jan-09 3:49 
GeneralRe: Monitor System Pin
Anubhava Dimri11-Jan-09 17:47
Anubhava Dimri11-Jan-09 17:47 
AnswerRe: Monitor System Pin
EliottA10-Jan-09 20:54
EliottA10-Jan-09 20:54 
GeneralRe: Monitor System Pin
Anubhava Dimri11-Jan-09 17:45
Anubhava Dimri11-Jan-09 17:45 
AnswerRe: Monitor System Pin
Eddy Vluggen12-Jan-09 0:10
professionalEddy Vluggen12-Jan-09 0:10 
GeneralRe: Monitor System Pin
EliottA12-Jan-09 1:00
EliottA12-Jan-09 1:00 
GeneralRe: Monitor System Pin
Anubhava Dimri12-Jan-09 17:36
Anubhava Dimri12-Jan-09 17:36 
GeneralRe: Monitor System Pin
EliottA13-Jan-09 2:47
EliottA13-Jan-09 2:47 
QuestionHow to assign shortcut keys for toolbar buttons? Pin
Prasadsm9-Jan-09 1:24
Prasadsm9-Jan-09 1:24 
Answer[Message Deleted] Pin
Scubapro9-Jan-09 1:50
Scubapro9-Jan-09 1:50 
GeneralRe: How to assign shortcut keys for toolbar buttons? Pin
Prasadsm9-Jan-09 2:02
Prasadsm9-Jan-09 2:02 
AnswerRe: How to assign shortcut keys for toolbar buttons? Pin
Scubapro9-Jan-09 2:17
Scubapro9-Jan-09 2:17 
GeneralRe: How to assign shortcut keys for toolbar buttons? Pin
JR2129-Jan-09 2:44
JR2129-Jan-09 2:44 
GeneralRe: How to assign shortcut keys for toolbar buttons? Pin
EliottA9-Jan-09 2:49
EliottA9-Jan-09 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.