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?
Re: Mimimizing the window created by a process
Quote:
Originally Posted by
zuhrs
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
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?
Re: Mimimizing the window created by a process
Hi,
It can be done using 6th argument in CreateProcess():
DWORD dwCreationFlags to SW_SHOWMINIMIZED
Re: Mimimizing the window created by a process
Quote:
Originally Posted by
cilu
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
Re: Mimimizing the window created by a process
Quote:
Originally Posted by
zuhrs
I need to minimize the application which launched the process
Dosn't ShowWindow(SW_MINIMIZE) work? :confused:
Or "the application which launched the process" has no window at all? :rolleyes:
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.
Re: Mimimizing the window created by a process
Quote:
Originally Posted by
VictorN
Dosn't ShowWindow(SW_MINIMIZE) work? :confused:
Or "the application which launched the process" has no window at all? :rolleyes:
ShowWindow takes 2 arguments - hwnd and cmdShow.
So minimize the application i need to get the hwnd for that. How can i get it?
Re: Mimimizing the window created by a process
Quote:
Originally Posted by
zuhrs
ShowWindow takes 2 arguments - hwnd and cmdShow.
Yes, if you are using plain Win APIs
Quote:
Originally Posted by
zuhrs
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
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
Re: Mimimizing the window created by a process
Quote:
Originally Posted by
zuhrs
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
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? :confused:
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