By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,516 Members | 1,369 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,516 IT Pros & Developers. It's quick & easy.

Maximizing and bringing another process main window on top

P: n/a
We have an app which must be single instance. When we start the app we
check if it is already running (using the Process object in the
System.Diagnostics namespace) locating it by the name of the process.
It is not the problem. When it is already running we have to maximize
the already started application and bring it on top of other windows.

When we find our process we get the main window handle from the Process
IntPtr hWnd = alreadyStartedAppProcess.MainWindowHandle;

We try to maximize it using Win32 API, using methods like :

public static extern int SendMessage(int hWnd, uint Msg, int wParam,
int lParam);

in that way:

//obtained from
Using it in that way only maximizing works.

public static extern bool ShowWindow(int hWnd,int nCmdShow);

in that way:

//info about ShowWindow can be found on

Using it in that way has the desired effect except in the case when our
already started app window is already maximized. Then it does not
appear on top of the other windows.

We have found a workaround which is something like:

ShowWindow(hWnd, SW_RESTORE);

which has the desired effect in all cases. The problem with it is that
we want to avoid unneccessary resizing of the form, which happens in
the above two calls.

if you have any suggestions please help
thanks in advance

Mar 17 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.