CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2007
    Posts
    66

    Question Mimimizing the window created by a process

    I am creating a process to launch mspaint application using the following code
    ::CreateProcess(0, strCmdLine.GetBuffer(0), 0, 0, FALSE, 0, 0, 0, &si, &pi)

    Once the application is launched, i need to minimise the paint application. How can i do it?

  2. #2
    Join Date
    Dec 2008
    Posts
    144

    Re: Mimimizing the window created by a process

    Quote Originally Posted by zuhrs View Post
    I am creating a process to launch mspaint application using the following code
    ::CreateProcess(0, strCmdLine.GetBuffer(0), 0, 0, FALSE, 0, 0, 0, &si, &pi)

    Once the application is launched, i need to minimise the paint application. How can i do it?
    Find the window and minimize it with ShowWindow function

  3. #3
    cilu's Avatar
    cilu is offline Moderator/Reviewer/MS MVP Power Poster cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+)
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,349

    Re: Mimimizing the window created by a process

    You mean you want to minimize the window of the application that launched the other process, of the window of the application that was launched?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Aug 2005
    Posts
    2

    Re: Mimimizing the window created by a process

    Hi,

    It can be done using 6th argument in CreateProcess():
    DWORD dwCreationFlags to SW_SHOWMINIMIZED

  5. #5
    Join Date
    Apr 2007
    Posts
    66

    Re: Mimimizing the window created by a process

    Quote Originally Posted by cilu View Post
    You mean you want to minimize the window of the application that launched the other process, of the window of the application that was launched?
    I need to minimize the application which launched the process

  6. #6
    Join Date
    Jan 2003
    Location
    Wallisellen (Zürich), Switzerland
    Posts
    16,178

    Re: Mimimizing the window created by a process

    Quote Originally Posted by zuhrs View Post
    I need to minimize the application which launched the process
    Dosn't ShowWindow(SW_MINIMIZE) work?
    Or "the application which launched the process" has no window at all?
    Victor Nijegorodov

  7. #7
    cilu's Avatar
    cilu is offline Moderator/Reviewer/MS MVP Power Poster cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+) cilu has a reputation beyond repute (3000+)
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,349

    Re: Mimimizing the window created by a process

    You can also try to send a WM_SYSCOMMAND with SC_MINIMIZE to the application's main window. But ShowWindow(SW_MINIMIZE) for the application's main window, should do the job.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  8. #8
    Join Date
    Apr 2007
    Posts
    66

    Re: Mimimizing the window created by a process

    Quote Originally Posted by VictorN View Post
    Dosn't ShowWindow(SW_MINIMIZE) work?
    Or "the application which launched the process" has no window at all?
    ShowWindow takes 2 arguments - hwnd and cmdShow.
    So minimize the application i need to get the hwnd for that. How can i get it?

  9. #9
    Join Date
    Jan 2003
    Location
    Wallisellen (Zürich), Switzerland
    Posts
    16,178

    Re: Mimimizing the window created by a process

    Quote Originally Posted by zuhrs View Post
    ShowWindow takes 2 arguments - hwnd and cmdShow.
    Yes, if you are using plain Win APIs
    Quote Originally Posted by zuhrs View Post
    So minimize the application i need to get the hwnd for that. How can i get it?
    Since you created a window in your application (and you didn't say you hadn't done it) that you got somewhere in your code this window handle returned by one of the Win API such as CreateWindow(Ex) or CreateDialog or something similar
    Last edited by VictorN; December 3rd, 2008 at 06:34 AM.
    Victor Nijegorodov

  10. #10
    Join Date
    Apr 2007
    Posts
    66

    Re: Mimimizing the window created by a process

    If I have the handle and try doing all this

    ::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
    SendMessage(hwnd, SW_SHOW,0,0);
    ShowWindow(hwnd, SW_SHOW);
    SetForegroundWindow(hwnd);
    BringWindowToTop(hwnd);

    Still I am not able to bring the window to top

    I asked about minimizing the parent window because i need the focus on the newly created application, but it is not happening

  11. #11
    Join Date
    Jan 2003
    Location
    Wallisellen (Zürich), Switzerland
    Posts
    16,178

    Re: Mimimizing the window created by a process

    Quote Originally Posted by zuhrs View Post
    If I have the handle and try doing all this

    ::SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
    .....
    Still I am not able to bring the window to top
    What is the hwnd you are using here?

    Quote Originally Posted by zuhrs View Post
    I asked about minimizing the parent window because i need the focus on the newly created application, but it is not happening
    What is "not happening"? Minimizing of your application window? Or what?
    Victor Nijegorodov

  12. #12
    Join Date
    Apr 2007
    Posts
    66

    Re: Mimimizing the window created by a process

    The parent window is creating a process and I am not able to bring the newly created window to top. For this reason i have tried to minimise the parent window so that the focus will be on the newly created application.
    In short I need to have the newly created application in the top. How can i do that

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width