473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 10883
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: alvis | last post by:
hi i have a windows service that uses an excell workbook when i create the excell app i cant distroy it after i am finished i am using this code whats wrong? thanks Dim processes1(), p1 As...
1
by: Sanjay Seshasainam | last post by:
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...
2
by: JohnJohnUSA | last post by:
I am new to Python. How do I get the following program to appear initially with the window maximized? Thanks for your help! from Tkinter import * # set up the window itself top = Tk() F =...
11
by: garyusenet | last post by:
For this first time today I used the System.Diagnositcs namespace to launch a program from my c# code. The program launches OK but I have something which has completely stumped me. The...
3
dmjpro
by: dmjpro | last post by:
i want to maximize a window after opening it using ... window.open how can i do this using JS plz help me out ... thanx in advance ....
1
by: Tombo | last post by:
I've been studying this solution, yet can not duplicate. http://www.thescripts.com/forum/thread351439.html I have a form with a single button. When the button is clicked, I want Internet...
0
by: guilabonte | last post by:
How can I set the position and the size of a process like the security center. (I use visual studio .net 2005 and c#) If I use this code for notepad that work fine : Process p...
4
by: =?Utf-8?B?SHVleQ==?= | last post by:
I need to hide the new window started from the code below. If I run as is, the window is visible. If I comment out the code that sets a different user, domain, and password the window is hidden...
2
by: aj | last post by:
SQL Server 2005 64-bit 9.00.3042 SP2 While working in SQL Server Mgmt Studio, I wish to maximize/minimize the window (or I guess the tab on the window) in which I type SQL for execution (in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.