Keeping Focus of a Window

Blitz3D Forums/Blitz3D Programming/Keeping Focus of a Window

Midnight(Posted 2004) [#1]
When I run an .exe file using ExecFile() from Blitz3D, the window with my game loses focus, even if the executable I'm running does not use any graphics functions.

Is there a way to regain focus?


jfk EO-11110(Posted 2004) [#2]
if the blitzapp runs in windowed mode, then yes. If it was fullscreen then no since this will pause the blitzapp.

You can write a function in a decls file, I guess you need to use the PositionWindow Function, a function of the user32.dll AFAIK. I remember It tried this a long time ago, and Things like WindowSetfocus, BringWindowToTop, ShowWindow simply refused to work, so I used PositionWindow with the topmost parameter, this worked.

So you would need to run the other exe,then wait some seconds, then force the blitzapp to gain focus again.

EDIT - ouch - forget POsitionWindow, in fact the Syntax is:
SetWindowPos...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/SetWindowPos.asp


Midnight(Posted 2004) [#3]
Hi JFK,

thanks for the tip... unfortunately I can't get it to go back into focus. I can move my window around no problem (so i know the command works), but even so it stays deactivated.

I've found this in the forums as well, as an "unstick" function:

SetWindowPos (GetActiveWindow (), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

So obviously it works for others - no idea why it doesn't for me. Will keep trying, but if you have ideas, please let me know.

Thanks again!


Midnight(Posted 2004) [#4]
OK, I also see your old post now, JFK:

SetWindowPos(hwnd,-1,0,0,0,0,3)

that works ok. It refuses to get full Focus whatever I do, but it doesn't really matter since I got the Mouse Coords and Action anyway.



Since my game is keyboard driven, I need full focus back. I've tried playing with the second parameter, but no luck.

Anyone have any suggestions?