Link to home
Start Free TrialLog in
Avatar of TopCatTom
TopCatTom

asked on

how to pass a function as parameter (creating a callback function)

hi,

I'm new to Powerbuilder Programming, so I come up with a simple question.
How can I pass a function as an argument to another function?

What I want to do is:
I want to get a list of all windows (including dialogs) that are visible on the screen. Therefore I use the API-function
long EnumWindows(long hwnd, long lParam) library 'user32.dll'
To this function I have to provide a callback function (as first parameter) that is called if EnumWindows() finds a window.
It should look somehow like this: EnumWindows(ADDRESS_OF(of_myCallback), 0)

Tom
Avatar of AFI
AFI

Hello.  In PB all functions are recursive, you only have to call the function inside itself.
I made what you are trying.  What I recomend you is to use the following APIs.

Private Function Long GetWindow(long haWnd, long wCmd) Library "user32"
Private Function Long GetWindowTextA (long hWind, ref String lpString, long cch) Library "user32"
Private Function Long GetWindowTextLengthA(long hanWnd) Library "user32"
Private Function Boolean IsWindowVisible (long handWnd) Library "user32"

I you need something else please tell me.
ASKER CERTIFIED SOLUTION
Avatar of RichBianco
RichBianco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial