0

I'm writing a lua program that needs to call an external popup (let's call it Poppy) provided as an external library/API by another active programme (environment is Windows).

Poppy has a bad habit; when invoked, it pops up, does its work and then vanishes -- leaving the current Lua dialog hidden behind Poppy's parent program.

After calling Poppy, dlg.BRINGFRONT="YES" will bring the iup dialog dlg to the front.

Is there a technique to identify what dlg should be -- i.e. what was the topmost iup dialog before the external API was invoked?

I've read the iup documentation and can't see a way to do this. However, as I need to call Poppy in a large number of instances, I'd like to simplify the process of bringing the current dialog to the front.

I'm invoking Poppy thus:

local res = Poppy('INDI')
dlg.BRINGFRONT="YES"
return res
ColeValleyGirl
  • 577
  • 15
  • 40

2 Answers2

0

Inside the code that invokes Poppy in Windows, you can call:

HWND dlg_handle = GetActiveWindow();

Then when Poppy returns, call:

SetForegroundWindow(dlg_handle);
Antonio Scuri
  • 1,046
  • 6
  • 10
0

I've succeeded in doing this using the Winapi library and the following code:

winapi = require ("winapi")
currentwin = winapi.get_foreground_window()
--invoke Poppy here and wait for control to return
currentwin:set_foreground()
ColeValleyGirl
  • 577
  • 15
  • 40