MaYaN
MaYaN

Reputation: 7006

How can I make a window stay on Top using .Net?

Is there a way to make a given window e.g. notepad or any other window to stay on top?

Please note this is not a question on how to make a Form or a WPF window stay on Top.

Upvotes: 2

Views: 75

Answers (1)

Axarydax
Axarydax

Reputation: 16623

I would use interop for this,

SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

to toggle always on top, and

SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

to deactivate.

courtesy of https://github.com/oazabir/AlwaysOnTop

Upvotes: 4

Related Questions