The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: stbfish on November 23, 2009, 01:37:28 AM

Title: How to get main window handle from process handle?
Post by: stbfish on November 23, 2009, 01:37:28 AM
How to get main window handle from process handle?
I want to set widow positon before it show on screen.
thanks.
Title: Re: How to get main window id from process id?
Post by: 2-Bit Chip on November 23, 2009, 01:42:22 AM
A window that edits its own position or editing of another window's position?
Title: Re: How to get main window id from process id?
Post by: stbfish on November 23, 2009, 01:52:25 AM
to 2-Bit Chip:
I have the process handle of an external process
created from within my application.How do I get the window handle from the process
handle?
thanks
Title: Re: How to get main window handle from process handle?
Post by: 2-Bit Chip on November 23, 2009, 02:11:19 AM
How did you run the process? ShellExecute or CreateProcess?
Title: Re: How to get main window handle from process handle?
Post by: sinsi on November 23, 2009, 02:19:41 AM
Have a look at EnumThreadWindows
Title: Re: How to get main window handle from process handle?
Post by: stbfish on November 23, 2009, 04:49:12 AM
How did you run the process? ShellExecute or CreateProcess?

CreateProcess, and i tried to change STARTUPINFO dwx, dwy, dwflags, not working.

other question here, after i invoke CreateProcess, the main window is already created or not?
i want to change window's position before it shows.
Title: Re: How to get main window handle from process handle?
Post by: MichaelW on November 23, 2009, 06:30:59 AM
The STARTUPINFO dwFlags member needs to include STARTF_USEPOSITION, and the x and y parameters for CreateWindowEx need to specify CW_USEDEFAULT.