Results 1 to 4 of 4

Thread: [2005][RESOLVED]WindowFromPointXY

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    164

    [2005][RESOLVED]WindowFromPointXY

    Private Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    Dim ptx As Long = System.Windows.Forms.Cursor.Position.X
    Dim pty As Long = System.Windows.Forms.Cursor.Position.Y
    Dim OnhookWindow As Long = WindowFromPointXY(ptx, pty)
    If OnhookWindow <> Me.Handle Then
    DoSomething()
    End If
    End Sub

    i got the error message "Unmanaged code debugging" ? What is this?
    What Wrong With My Code?
    Last edited by edwinho; Jun 11th, 2007 at 05:38 AM.

  2. #2
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: WindowFromPointXY

    try changing this line
    vb Code:
    1. Dim OnhookWindow As Long = WindowFromPointXY(ptx, pty)

    to
    vb Code:
    1. Dim OnhookWindow As Long = WindowFromPoint(ptx, pty)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    164

    Re: WindowFromPointXY

    Thx!! tried but the result with same problem

    A call to PInvoke function windowsfrompointXY has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
    Last edited by edwinho; Jun 11th, 2007 at 04:30 AM.

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: WindowFromPointXY

    Whenever you are declaring an API function in .Net you need to change all Long variables to Integers. I belive this function also returns an IntPtr object.
    Heres how it should look:

    VB.NET Code:
    1. Private Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Integer, ByVal yPoint As Integer) As IntPtr
    2.  
    3. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    4.  
    5. Dim ptx As Integer = System.Windows.Forms.Cursor.Position.X
    6. Dim pty As Integer = System.Windows.Forms.Cursor.Position.Y
    7. Dim OnhookWindow As IntPtr = WindowFromPointXY(ptx, pty)
    8. If Not OnhookWindow = Me.Handle Then
    9. DoSomething()
    10. End If
    11. End Sub
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

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