Reputation: 41
I want to make a window topmost in a C# application. i need to make it so that while the window is loaded(the application is invoked by a third party software) it will be on top and user can browse to other windows if he needed.
I used
this.Topmost = true;
this.TopMost=false;
but it dont have any effect.
Upvotes: 0
Views: 2089
Reputation: 3509
UPDATE
READ THIS http://social.msdn.microsoft.com/forums/en-US/winforms/thread/bf3117f8-d83d-4b00-8e4f-7398b559a2dd/
If the forms are in different applications, you can get the window you want to bring to front by calling the FindWindow API, and SetForegroundWindow API to bring it to front, for more information, you can read these likes
FindWindow
http://msdn.microsoft.com/en-us/library/ms633499(VS.85).aspx
SetForegroundWindow http://msdn.microsoft.com/en-us/library/ms633539(VS.85).aspx
Upvotes: 0
Reputation: 769
I can suggest you to use native API. SetWindowPos function from user32.dll
something like this, but it should be converted to C# code, i think it wouldn't be difficult. HWND_TOPMOST flag is just what you needed
RECT rect;
// get the current window size and position
GetWindowRect(hWnd, &rect );
// now change the size, position, and Z order
// of the window.
SetWindowPos(hWnd , // handle to window
HWND_TOPMOST, // placement-order handle
rect.left, // horizontal position
rect.top, // vertical position
rect.right, // width
rect.bottom, // height
SWP_SHOWWINDOW );// window-positioning options
Upvotes: 0
Reputation: 10800
TopMost
only applies to forms within your application. If you want to bring your form to the top of other applications running on your computer, I suggest you take a look at this question:
Bringing window to the front in c# using win 32 api
Upvotes: 1