FSX and stay on top

Good day all,
this is my first post in this forum, and probably my question has been answered some where, but the search engine did not find anything relevant.

What is the way to do for have a stay on top window over the fsx window?

I use C++Builder, and, in windowed mode, all goes well until the main window of FSX lost the focus.
When it recovers the focus, my window (wich is with fsStayOnTop style), is sent in the background and hidden behind FSX.
In full screen mode, that doesn't work at all...

Perhaps someone who has yet built such a window can point me in the right direction?

With best regards,

For this, you need to know at a minimum your window handle, and Flight Simulator's.

You can use FindWindowEx in the Windows API (user32.dll) using "FS98MAIN" as the window class, and optionally "Microsoft Flight Simulator X" is the window title. This gets you the handle to the main window for the next step, described using older VB code here, but the principle is the same:


Hope this helps,

Hi Etienne,
thanks for this very interresting link... now I understand why all the solutions laying on API calls do not work and I have a work around to make the things working.

I'll make a test asap.

Best regards,

Good point on localization and you are quite right it's never a good idea to use the window name. Perhaps the only time I can think of it being of use is when multiple windows have the same class (eg, FS98CHILD for example).

If you want to get an idea of what controls and message loops (read windows here), you can use Spy++ if you have Visual Studio as it will show anything out there registered as a window class in Windows. For .NET application, ManagedSpy++ (http://msdn.microsoft.com/msdnmag/issues/06/04/ManagedSpy/) does the same thing, but makes it .NET friendly.


I also forgot to add that a window can only be moved on top of other windows it the same process space (windows created by the same process). It's not possible in Windows XP to change the owner of a window after it's been created (although you can change the parent within the same process space).

In full screen mode, FSX runs as the topmost window in its process space because that's the behavior of DirectX.

If your window is created from a DLL loaded by FSX (example, a panel or dialog), they will be owned by the FSX process so you should be ok. Child windows show in front of the parent window, even if the parent window is marked as topmost. Child windows in FSX have the class name FS98CHILD, including gauges.

If your window is created by an EXE, it will be in a different process space and I'm not sure there's a way to make it show in front of the main DirectX window if the DirectX app is in full screen mode. It also seems that DirectX resets the stack at every frame, making sure that your out of process window becomes hidden.

One exception to this may be the MessageBox() window, because that's an API modal window owned by the desktop.


Last edited: