You can get top most behavior by setting the form property
I don't know what I did wrong before but this just works now. I had been
messing with it and found it didn't work for forms, I must have been
screwing something up. I ended up doing
// couldn't find a .NET-way to bring the window
// to top, reverting to old Win32 functions...
[DllImport("User32.dll")]
public static extern Int32 FindWindow(String lpClassName,String
lpWindowName);
[DllImport("User32.dll")]
public static extern Int32 SetForegroundWindow(int hWnd);
private void triMain_Click(object sender, System.EventArgs e)
{
Show();
int hWnd = FindWindow(null, "Pacemaker"); // Win32 API, don't want
to use this
SetForegroundWindow(hWnd); // Wim32 API, don't want to use this
}
Now it is clean:
Show();
TopMost = true;
TopMost = false;
I am resetting TopMost to false because I just want it to bring the form to
top when the tray icon is clicked and not stay on top persistently.
Thank you!
Martin.