|
-
Jun 11th, 2007, 03:49 AM
#1
Thread Starter
Addicted Member
[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.
-
Jun 11th, 2007, 04:13 AM
#2
Fanatic Member
Re: WindowFromPointXY
try changing this line
vb Code:
Dim OnhookWindow As Long = WindowFromPointXY(ptx, pty)
to
vb Code:
Dim OnhookWindow As Long = WindowFromPoint(ptx, pty)
-
Jun 11th, 2007, 04:17 AM
#3
Thread Starter
Addicted Member
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.
-
Jun 11th, 2007, 05:01 AM
#4
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:
Private Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Integer, ByVal yPoint As Integer) As IntPtr
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim ptx As Integer = System.Windows.Forms.Cursor.Position.X
Dim pty As Integer = System.Windows.Forms.Cursor.Position.Y
Dim OnhookWindow As IntPtr = WindowFromPointXY(ptx, pty)
If Not OnhookWindow = Me.Handle Then
DoSomething()
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|