Maximize a process window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sanjay Seshasainam

    #1

    Maximize a process window

    How can I maximize a process window

    I am using the Process class in System.Diagnost ics. 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 MainWindowHandl e how do I
    maximize the window ?

    Thanks,
    Sanjay

    Process[] myProcess;
    myProcess = Process.GetProc essesByName("pr ocess_name");

    foreach (System.Diagnos tics.Process instance in
    myProcess)
    {
    string windowTitle = instance.MainWi ndowTitle;
    if ( windowTitle == "WINDOW_TIT LE" )
    {
    // How can I maximize the window here ??
    void *windowHandle =
    instance.MainWi ndowHandle.ToPo inter();
    }
    }

  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Maximize a process window

    Hi,

    Call the SendMessage API function through P/Invoke, sending the WM_MAXIMIZE
    message to the main process window. As you already have the MainWindowHandl e
    (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

    Bring the power of unit testing to VS .NET IDE

    "Sanjay Seshasainam" <sanjaynetclass @yahoo.com> wrote in message
    news:075601c384 62$99157e90$a40 1280a@phx.gbl.. .[color=blue]
    > How can I maximize a process window
    >
    > I am using the Process class in System.Diagnost ics. 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 MainWindowHandl e how do I
    > maximize the window ?
    >
    > Thanks,
    > Sanjay
    >
    > Process[] myProcess;
    > myProcess = Process.GetProc essesByName("pr ocess_name");
    >
    > foreach (System.Diagnos tics.Process instance in
    > myProcess)
    > {
    > string windowTitle = instance.MainWi ndowTitle;
    > if ( windowTitle == "WINDOW_TIT LE" )
    > {
    > // How can I maximize the window here ??
    > void *windowHandle =
    > instance.MainWi ndowHandle.ToPo inter();
    > }
    > }
    >[/color]

    Comment

    Working...