|
-
May 2nd, 2002, 08:54 AM
#1
Thread Starter
Hyperactive Member
How to get to currently displayed form
I`m in a seperate DLL to whoever owns whats on the screen,so i need a way of getting to a control thats there.
An app opens a datagrid of some sort, bound to a database. I want to manipulate some of the figures in one of the columns.
Any ideas?
-
May 2nd, 2002, 09:06 AM
#2
The way I've done that is:
to get into Spy++, find out what the window class for the object is.
Then EnumWindows for each parent then EnumChildWindows until I get the hWnd of the object I want. You can also use FindWindow to get the parent. if the text of the parent Window is always fixed. I can scrounge up code later if you don't know how to do this.
-
May 2nd, 2002, 09:20 AM
#3
Thread Starter
Hyperactive Member
If you have code to hand it would be great, but i think i know what you are getting at, and will look up the functions you just mentioned.
Can i do this programmatically, so that it will always get me the form/control i need? Will it work 100% of the time?
-
May 2nd, 2002, 10:45 AM
#4
Thread Starter
Hyperactive Member
(God, the `Search` functionality on this site is just terrible, isnt it! Has anyone managed to find anything with it?)
Ok, i dug up some code from the web, sort of got it working. Heres what i got (after i made it work!!)
Public Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
Dim slength As Long, buffer As String
Dim retval As Long
Winnum = Winnum + 1
slength = GetWindowTextLength(hWnd) + 1
If slength > 1 Then
buffer = Space(slength)
retval = GetWindowText(hWnd, buffer, slength)
MyRetval = MyRetval & "Window #" & Winnum & " : "
MyRetval = MyRetval & Left(buffer, slength - 1)
MyRetval = MyRetval & vbCrLf
End If
EnumWindowsProc = 1 ' return value of 1 means continue enumeration
End Function
it returns more than just window titles though - i get all sorts of junk. How do i just get windows?
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
|