468,248 Members | 1,513 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,248 developers. It's quick & easy.

Maximize a process window

How can I maximize a process window

I am using the Process class in System.Diagnostics. I can
identify the specific process I want using the window
title after that I want to maximize the window. I can get
the handle for the window using MainWindowHandle how do I
maximize the window ?

Thanks,
Sanjay

Process[] myProcess;
myProcess = Process.GetProcessesByName("process_name");

foreach (System.Diagnostics.Process instance in
myProcess)
{
string windowTitle = instance.MainWindowTitle;
if ( windowTitle == "WINDOW_TITLE" )
{
// How can I maximize the window here ??
void *windowHandle =
instance.MainWindowHandle.ToPointer();
}
}

Jul 21 '05 #1
1 10574
Hi,

Call the SendMessage API function through P/Invoke, sending the WM_MAXIMIZE
message to the main process window. As you already have the MainWindowHandle
(you don't need to get a pointer from it, by the way), the rest is pretty
straightforward:

1) Declare the SendMessage prototype with the DllImport attribute (please
refer to MSDN for details on this)
2) Find out the numeric value of the WM_MAXIMIZE constant (look it up in the
winuser.h file. You should have one if you have Visual C++ installed)
3) Call the declared SendMessage method passing necessary parameters.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Sanjay Seshasainam" <sa************@yahoo.com> wrote in message
news:07****************************@phx.gbl...
How can I maximize a process window

I am using the Process class in System.Diagnostics. I can
identify the specific process I want using the window
title after that I want to maximize the window. I can get
the handle for the window using MainWindowHandle how do I
maximize the window ?

Thanks,
Sanjay

Process[] myProcess;
myProcess = Process.GetProcessesByName("process_name");

foreach (System.Diagnostics.Process instance in
myProcess)
{
string windowTitle = instance.MainWindowTitle;
if ( windowTitle == "WINDOW_TITLE" )
{
// How can I maximize the window here ??
void *windowHandle =
instance.MainWindowHandle.ToPointer();
}
}


Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by alvis | last post: by
1 post views Thread by Sanjay Seshasainam | last post: by
2 posts views Thread by JohnJohnUSA | last post: by
4 posts views Thread by =?Utf-8?B?SHVleQ==?= | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.