From: Claudio on
I call a ShellExecute like this and then I'd like to resize the window. How
can I get the HWND from the HINSTANCE?
thanks

HINSTANCE result = ShellExecute(NULL,
"open",
MPEG4_DECODER,
URL,
NULL,
SW_SHOWNORMAL);


From: Igor Tandetnik on
Claudio <Claudio(a)discussions.microsoft.com> wrote:
> I call a ShellExecute like this and then I'd like to resize the
> window. How can I get the HWND from the HINSTANCE?
>
> HINSTANCE result = ShellExecute(...);

Which one? An application may create multiple windows, or none at all.

Assuming this particular application only creates one top-level window,
this is what you can do. First, ShellExecute only returns HINSTANCE for
backward compatibility. The return value is meaningless, except that
when it's less than 32 it's an error code (and any value greater than 32
indicates success).

You need to use ShellExecuteEx with SEE_MASK_NOCLOSEPROCESS flag, to
obtain process handle. Then you call WaitForInputIdle, to get the
process a chance to start up and actually create its main window. Use
GetProcessId to obtain the process ID. You can now close the process
handle with CloseHandle. Finally, enumerate all top-level windows with
EnumWindows, and for each window use GetWindowThreadProcessId to find
out whether it belongs to the process you are interested in.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


From: "CheckAbdoul" <checkabdoul at mvps dot on
Use ShellExecuteEx() or CreateProcess() instead of ShellExecute() which
will give you the process handle. You can enumerate through the top level
windows created by the process. Search for "CMainWindowIterator" in msdn.

--
Cheers
Check Abdoul
------------------

"Claudio" <Claudio(a)discussions.microsoft.com> wrote in message
news:226B247F-E75E-4764-8484-4793E3195FF6(a)microsoft.com...
>I call a ShellExecute like this and then I'd like to resize the window. How
> can I get the HWND from the HINSTANCE?
> thanks
>
> HINSTANCE result = ShellExecute(NULL,
> "open",
> MPEG4_DECODER,
> URL,
> NULL,
> SW_SHOWNORMAL);
>
>


From: Ben Voigt on
"CheckAbdoul" <checkabdoul at mvps dot org> wrote in message
news:eUC0utRSGHA.3192(a)TK2MSFTNGP09.phx.gbl...
> Use ShellExecuteEx() or CreateProcess() instead of ShellExecute() which
> will give you the process handle. You can enumerate through the top level
> windows created by the process. Search for "CMainWindowIterator" in msdn.

Use CreateProcess and appropriately set the STARTUPINFO structure,
specifically:
DWORD dwX; DWORD dwY; DWORD dwXSize; DWORD dwYSize; DWORD
dwFlags;dwXIf dwFlags specifies STARTF_USEPOSITION, this member is the x
offset of the upper left corner of a window if a new window is created, in
pixels. Otherwise, this member is ignored. The offset is from the upper left
corner of the screen. For GUI processes, the specified position is used the
first time the new process calls CreateWindow to create an overlapped window
if the x parameter of CreateWindow is CW_USEDEFAULT.dwYIf dwFlags specifies
STARTF_USEPOSITION, this member is the y offset of the upper left corner of
a window if a new window is created, in pixels. Otherwise, this member is
ignored. The offset is from the upper left corner of the screen. For GUI
processes, the specified position is used the first time the new process
calls CreateWindow to create an overlapped window if the y parameter of
CreateWindow is CW_USEDEFAULT.dwXSizeIf dwFlags specifies STARTF_USESIZE,
this member is the width of the window if a new window is created, in
pixels. Otherwise, this member is ignored. For GUI processes, this is used
only the first time the new process calls CreateWindow to create an
overlapped window if the nWidth parameter of CreateWindow is
CW_USEDEFAULT.dwYSizeIf dwFlags specifies STARTF_USESIZE, this member is the
height of the window if a new window is created, in pixels. Otherwise, this
member is ignored. For GUI processes, this is used only the first time the
new process calls CreateWindow to create an overlapped window if the nHeight
parameter of CreateWindow is
CW_USEDEFAULT.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/startupinfo_str.asp

>
> --
> Cheers
> Check Abdoul
> ------------------
>
> "Claudio" <Claudio(a)discussions.microsoft.com> wrote in message
> news:226B247F-E75E-4764-8484-4793E3195FF6(a)microsoft.com...
>>I call a ShellExecute like this and then I'd like to resize the window.
>>How
>> can I get the HWND from the HINSTANCE?
>> thanks
>>
>> HINSTANCE result = ShellExecute(NULL,
>> "open",
>> MPEG4_DECODER,
>> URL,
>> NULL,
>> SW_SHOWNORMAL);
>>
>>
>
>