I am trying to open an always on top form from a system tray application, basically for showing some instant notifications.
For achieving always on top behavior, I followed the instructions in the reference1 and reference2.
The code in the references works only if I add following code on Frm_Load.
private void Frm_Load(object sender, EventArgs e) {
this.TopMost = true;
this.Activate();
this.Focus();
this.BringToFront();
SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); // code from references
}
The code only works when I run it in Visual Studio 2019. It does not work at the built exe. In the exe form does not open as top, also not stay always on top, it stays under the other windows. I disabled the visual studio code optimization in the build settings but it did not help.
What can cause that the code working differently in the IDE and in the exe? How can I solve this issue, and show an on top window like Winamp?