Announcement

Collapse
No announcement yet.

Result from "CodePtr(EnumChildProc)" ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Result from "CodePtr(EnumChildProc)" ?

    I wrote a universal search engine for windows/controls of all kind, using both of the following methods:
    a) Thread_ID = GetWindowThreadProcessId(lhWnd, ProcessID)
    lRet = EnumThreadWindows(ThreadID, CodePtr(EnumThreadProc), lParam)
    b) lRet = EnumChildWindows
    Code:
       
    Inside the code  I'm using a function to enumerate all windows and controls.  
    Function EnumChildWindowsByParam (lhWnd As Long) As Long
       Local lParam As Long
    	Local lRet As Long
    ==>   lRet = EnumChildWindows(lhWnd, CodePtr(EnumChildProc), lParam)
    	Function = lRet
    End Function
    As you can see, a code pointer is used to access function EnumChildProc. This function however as defined gives back a result which I'd like to use to finish searching when the desired window/control was found via its parameters. I don't remember that the SDK offers directly a result from a function pointed to.
    I'd be glad to be wrong.
    Norbert Doerre

  • #2
    Pass the address of "lparam" and fill that with the desired result.

    i.e
    Code:
      LOCAL lParam AS LONG
      iRet = EnumChildWindows (hWnd, CODEPTR (callbackProc), BYVAL VARPTR(lparam))
      IF ISTRUE iRet THEN   ' enumeration succeeded 
           Value_I_Want = lparam
      .....
    FUNCTION CallBackProc (BYVAL hWnd AS LONG ,  lparam AS LONG) AS LONG
    
       ' whatever 
        lparam = value_to_return
    
    END FUNCTION
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment

    Working...
    X