How can i make the windows application always on top of every application, including those which are in full screen?

Thanks for any replies.

Dani AI

Generated

is right that TopMost only affects the normal desktop Z-order. The catch is running into is exclusive full-screen: the game owns the swap chain and bypasses the normal compositor, so a regular WinForms window (even TopMost) cannot draw over it. hinted at the practical answer: either run the other app in windowed/borderless mode, or render your UI inside the full-screen app itself.

If the target app can be set to windowed or borderless, pin your editor reliably with SetWindowPos (more robust than just Form.TopMost). VB.NET example:

Imports System.Runtime.InteropServices

Public Class Form1
  <DllImport("user32.dll", SetLastError:=True)>
  Private Shared Function SetWindowPos(hWnd As IntPtr, hWndInsertAfter As IntPtr,
                                       X As Integer, Y As Integer, cx As Integer, cy As Integer,
                                       uFlags As UInteger) As Boolean
  End Function

  Private Shared ReadOnly HWND_TOPMOST As New IntPtr(-1)
  Private Const SWP_NOMOVE As UInteger = &H2UI
  Private Const SWP_NOSIZE As UInteger = &H1UI
  Private Const SWP_NOACTIVATE As UInteger = &H10UI

  Protected Overrides Sub OnShown(e As EventArgs)
    MyBase.OnShown(e)
    SetWindowPos(Me.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE)
  End Sub
End Class

For true full-screen you have only workarounds:

  • Switch the game to borderless/windowed; then the code above works.
  • Provide an in-game overlay by drawing your editor with the same graphics API as the game (Direct3D/OpenGL). This often requires injection/hooking and may violate anti-cheat/EULAs; proceed with care.
  • Register a global hotkey that minimizes the full-screen app and activates your editor, or place the editor on a second monitor.

In short: you cannot reliably float a normal window above exclusive full-screen; design for windowed/borderless or integrate the editor into the full-screen renderer.

Recommended Answers

All 5 Replies

How can i make the windows application always on top of every application, including those which are in full screen?

Thanks for any replies.

Hi

When you scroll down on form's property you will see an option TopMost. You just have to set that to true...(Make sure your forms are either maximized / same size)

Hope it will help!

Thanks for the reply wednesday but it only works when the other app is in windowed mode, it doesn't work when it is in full screen.

This is what i want to do. When i'm using an application, which is in full screen mode(ex. games), i want to be able to use a text editor. The TopMost property in my app doesn't work when i'm using an application in full screen mode.

Try this. Add a button or menu item to your form and add this code.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.TopMost = False
        Dim proc As Process = Process.Start("notepad.exe")
        proc.WaitForExit()
        proc.Close()
        Me.TopMost = True
    End Sub

Wayne's technique is about the only way you're going to pull this off if you're using 'real' windows.

If you've noticed in many games which 'take over your screen', the developers actually recreate Notepad within the game if text editing is required - everything 'Windows' in a well formed Full Screen game has to be reverse engineered and recreated within the full screen environment.

Even with Wayne's idea, if your app takes over resolution as well (as many games do) then the switch back to Windows mode is going to look, well, weird. You've probably alt-tabbed out of a game at some point and seen humongous icons on your desktop - that's the effect.

Try the suggestion, but consider how you might improve upon it by creating your own Virtual Notepad which works within your game.

Happy coding!

Ned

thanks for the reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.