Results 1 to 4 of 4

Thread: How to get to currently displayed form

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290

    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?

  2. #2
    jim mcnamara
    Guest
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    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?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    (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
  •  



Click Here to Expand Forum to Full Width