You're right - oops.
On that note, here's a routine not invovling an array. It's based on mousePosX() and a check whether the main window is active.
startblue USERID,KEY
dbpwindow = createGadgetFromWindow(mainWindow())
#constant user32num 1
load dll "user32.dll",user32num
do
rem only get the gum and pgum if DBpwindow is active and under mouse :)
if mousePosX(dbpwindow)>=0 and getWindowActive(dbpwindow)=1 `if you aren't using the DBpro window as your main window, change the first condition to 'if mousePosX(*windowhandle*)>=0'
gum = gadgetUndermouse()
rem only get the parent if it's a child gadget (so parent isn't Windows' desktop handle
if gum<>dbpwindow
pgum = gadgetHandle(gum)
else
pgum = 0
endif
else
gum = 0
pgum = 0
endif
rem print gum and pgum
print gum;" ";pgum
sleep 100
rem close if close button or escapekey
repeat
getEvent
if (eventType()=0x10 and eventSource()=dbpwindow) or escapeKey() then end
until eventType()=0
loop
end
function getWindowActive(hwindow)
local returnval
lhactive = call dll(user32num,"GetActiveWindow")
if windowHandle(hwindow)=lhactive
returnval = 1
else
returnval = 0
endif
endfunction returnval
Note that mainWindow() has a minor bug in it, and this code will still crash if the user starts the app, then immediately switches to IE and let's it load in the background. I haven't found a way around this, but if I do I'll post again.
-Xol