|
-
Jul 10th, 2004, 04:26 AM
#1
Thread Starter
Fanatic Member
WindowFromPoint
hello i used this vb6 code in order to get the handle of any window from a point.
VB Code:
Dim myhwnd As Long
Dim typPt As POINTAPI
Dim hwnd As Long
typPt.x = MY_X
typPt.y = MY_Y
myhwnd = WindowFromPoint(typPt.x, typPt.y)
now the problem is that this code seems not to work with vb.net.
I could get a handle to any window even if it did not belong to the form.
Now the following code can find the handle a control that does only exist on the form ,i think. Is there a way to get a handle to any control of any windows window ?
thanks !
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pt As System.Drawing.Point
pt.X = 500
pt.Y = 100
Dim co As Control
co = Me.GetChildAtPoint(pt)
If Not co Is Nothing Then
MsgBox(co.Name)
Else
MsgBox("NO CONTROL FOUND", MsgBoxStyle.ApplicationModal)
End If
End Sub
-
Jul 10th, 2004, 07:13 AM
#2
I wonder how many charact
You will only be able to retrieve controls (windows or others) that are part of your application using those functions.
However, you can, just like in your vb6 code, use your WindowFromPoint function. In VB.NET, you need to change any Long variables to Integers, because Integers are 4 bytes long in .Net.
VB Code:
Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Integer, ByVal yPoint As Integer) As Integer
Private Structure typPT 'public or private, up to you
Public x As Integer
Public y As Integer
End Structure
Private myhwnd As Integer
typPt.x = MY_X
typPt.y = MY_Y
myhwnd = WindowFromPoint(typPt.x, typPt.y)
Last edited by nemaroller; Jul 10th, 2004 at 07:24 AM.
-
Jul 10th, 2004, 12:46 PM
#3
Thread Starter
Fanatic Member
did microsoft restrict this function for security reasons ?
-
Jul 11th, 2004, 08:49 PM
#4
I wonder how many charact
Maybe, maybe not... I think it has more to do with how the .Net framework is designed to exist on a system, which, like Java, is designed to operate mostly system-independent. Low-level calls are not part of the framework, since they are operating system dependent.
So while you can call on Win32 API functions like WindowFromPoint on a Windows box, the .Net framework itself can run on a Linux or Unix box, which obviously has no support for WindowFromPoint.
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
|