With the STYX plug-in (version 1.10- to be released soon), you can create Callback functions in DBPro.
What are Callback functions? As the name suggests, these are functions that are called by other functions. However, the calling functions are not part of your program but live in external DLLs. This can be quite useful for a plugin system, for example. Also some of the WinAPI functions require a callback function.
This snippet shows the WinAPI function named "EnumWindows", which calls the DBPro function "EnumWindowsProc" once for each window that is currently active.
rem Register a function for Callback
REGISTER FUNCTION : EnumWindowsProc() : CALLBACK 1, 2
rem get the callback pointer
pEnumWindowsProc = CALLBACK PTR(1)
rem execute EnumWindows in user32.dll
rem this function requires a pointer to a function that will
rem be called once for each active Window. It will pass the
rem Handle of the window and a user defined value (in this case 0)
Load Dll "user32.dll", 1
Call Dll 1, "EnumWindows", pEnumWindowsProc, 0
rem wait for input and clean up
wait key
Delete Dll 1
end
function EnumWindowsProc()
rem if this function was called during the registration process
rem we want to exit it immediately.
if REGISTER CALL() then ExitFunction
rem get the first argument that was passed to this function
rem This is a Window Handle (see above)
whandle = CALLBACK ARG(1)
rem With GetWindowTextA we obtain the caption of the window
wname$ = space$(256)
Call Dll 1, "GetWindowTextA", whandle, wname$, 255
rem if the window has a caption then print it.
if wname$ <> ""
print wname$
endif
rem set the result of this callback function to 1
rem a value of 0 would stop EnumWindows from calling this function
CALLBACK RESULT 1
endfunction