Announcement

Collapse
No announcement yet.

Capturing Windows events

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Matthew Berg
    replied
    I need to write a DLL in PBDLL 5.0 that will capture a mousemove event regardless of where it happens.
    You will want to install a Mouse Hook with the SetWindowsHookEx() and UnhookWindowsHookEx() functions.

    Leave a comment:


  • Scott Turchin
    replied
    I believe it was Jim that showed me this works better and has less chance of blowing up or beingconfused for some static handle or variable..

    Code:
    'This is for a splash screen, show for 3.5 seconds, the DDT dialog is sDlg
    'It also works for checking the time every second, although more code is required...(Used in my nuke-time server..)
    %IDT_TIMER1 = %WM_USER + 901
    Global sDlg   As Long
    
    'In Your Dialog Procedure:
    
        Case %WM_INITDIALOG
              MousePtr 11 'Busy
              SetTimer  sDlg, %IDT_TIMER1,  3500, ByVal %NULL
    
    
        Case %WM_DESTROY
             KillTimer sDlg,  %IDT_TIMER1
    
        Case %WM_TIMER
            Select Case CbWparam
              Case %IDT_TIMER1
                 MousePtr 0 'Not busy
                 Dialog End sDlg, 1
            End Select
    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    [This message has been edited by Scott Turchin (edited March 29, 2000).]

    Leave a comment:


  • Semen Matusovski
    replied
    I tested on following sample (Win2000)
    Code:
    #Compile Exe
    #Dim All
    #Register None
    #Include "Win32Api.Inc"
    %Test = 0
    Global nTicks As Long
    CallBack Function SubTest
       Incr nTicks
    End Function
    Function PbMain
       Local hDlg As Long
       $If %Test
       Dialog New 0, "0", 0, 0, 0, 0 To hDlg
       $EndIf
       Local ff As Long
       ff = SetTimer (hDlg, 6000, 50, CodePtr(SubTest))
       Do
          Dialog DoEvents
          If nTicks = 10 Then Exit Do
       Wend
       MsgBox Str$(KillTimer (hDlg, ff))
       $If %Test
       Dialog End hDlg, 0
       $EndIf
    
    End Function
    Works in any case (Test = 0/1)

    About Tom's information. It's correct in any case, but for hWnd <> 0, it possible to use "6000" (because SetTimer returns the same).

    [This message has been edited by Semen Matusovski (edited March 29, 2000).]

    Leave a comment:


  • Tom Hanlin
    replied
    SetTimer is a FUNCTION that returns the timer identifier that you need to use with KillTimer.

    ------------------

    Leave a comment:


  • Jason W Evans
    Guest started a topic Capturing Windows events

    Capturing Windows events

    I need to write a DLL in PBDLL 5.0 that will capture a mousemove event regardless of where it happens.

    The idea is this: I call a proc in the DLL from VB that will start a timer in the DLL. The DLL should be able to capture a mousemove event regardless of where it happens in Windows, when this happens the timer is reset. If no mousemove event has occurred when the timer fires, the DLL calls a VB proc, using Call DWORD to notify that time is up. Hope this is clear.

    Another query: I have been using SetTimer and KillTimer to do some things, but KillTimer does not seem to work e.g.

    SetTimer 0, 6000, 5000, CodePtr(SubTest)

    This creates the timer fine, but

    KillTimer 0, 6000

    this does not kill the timer at all!

    Any ideas.

    Thanks.
Working...
X