Maintaining focus on a running program

Previous topic - Next topic

Gary

Is there any way (GLBasic or an inline C routine) of forcing the focus back to the running GLBasic program?

I am running in full screen and I call a shell command at start up which loads and closes correctly but at this point focus is not handed back to the GLBasic program (I have the AUTOPAUSE turned off so it does still run and displays on the screen but keyboard inputs are not accepted until the screen is touched)

Thanks
Gary

MrTAToad

Its a common problem when you shell to another program (in any language).

What you would need to do (in C) is call a Windows function (most likely SetWindowPos) when the GLBasic program starts to force it to keep topmost position even when it is de-activated.

Gary

Cheers

Just looking on MSDN and they list a command

Code (glbasic) Select
HWND WINAPI SetActiveWindow(
  __in  HWND hWnd
);


would that be more appropriate as that just seems to return focus to the program where as setwinpos needs all the X,Y and size for the window?

Just need to find the DLL thats in and wrap it I guess

MrTAToad

That would probably only be suitable for the original program, unless you pass the Window handle to the program being called...

Gary

think I have found a simpler way.

When the program starts doing a SETSCREEN gives the focus to the program, so I called SETSCREEN again after I called the external program. focus seems to be returned to the GLBasic program :) Only question is, could having the second SETSCREEN in the program cause any hidden problems?

MrTAToad

Only if you had loaded sprites beforehand :)

Gary

hmm I do but cant see anything wrong with the display after doing it again, should SETSCREEN clear the sprites out then?

MrTAToad

You should clear them out before you use SETSCREEN, otherwise you could get corrupt graphics...

Gary

ok thanks for the tip, will work round and load the sprites after the second setscreen in that case, I only need to call the external program once so its not an issue

Kitty Hello

SETSCREEN to fullscreen might not work on the Mac. That's all.