473,325 Members | 2,712 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,325 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 10870
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.