Reputation: 1015
I have a form application, i want to it to be the the top most. i use
SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
this function, it works fine.But when task manager property always on top is checked it fails. And task manager will appear as the top most window. So my concern is, if there any way to achieve it, or we cant not do it with task manager. it will always appear on the top, or anything else i was missing, or doing wrong.
Upvotes: 1
Views: 996
Reputation: 91
you can try this if you just want your application is always at the top of other application.
private void timer1_Tick(object sender, EventArgs e)
{
this.TopMost = true;
}
Upvotes: 0
Reputation: 436
The MSDN say that HWND_TOPMOST
simply Places the window above all non-topmost windows.
In other words there are two groups of windows: non-topmost (usual) and topmost and you just sent your window to the other group.
If there is any other topmost window (= task manager in your case), you can switch between them as you normally would between non-topmost windows and they will be overlapping depending on which one is currently active.
If you would like to force your window to be always topmost, I guess you would have to watch for the window deactivation (WM_ACTIVATE
message) and then move your window up in the Z-order and also focus your window back - this way you would prevent problems like having your window the only one visible, but having the keyboard focus on another window.
Upvotes: 2