🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by David Thu, 26 Apr 2007 08:39
Start a Child Application in a Window
#2054
Author: David
Date: Thu, 26 Apr 2007 08:39
12 lines
1457 bytes
Is it possible to create a new process within (limited to) a given window of 
a running process - like for instance, Adobe Acrobat starting up to display 
a .pdf within Internet Explorer?
What I am hoping to do is to display files of different types from an 
archive within the window of a vcl control, using their varying display 
applications.
I have tried ShellExecute with the window parameter set to the handle of an 
existing control but this does not seem to help. Any other suggestions, 
please?
Or can someone suggest a simpler way of achieving the objective?
Regards,
David 
Re: Start a Child Application in a Window
#2059
Author: Remy Lebeau (TeamB)
Date: Thu, 26 Apr 2007 17:08
34 lines
2315 bytes
"David" <david@pedley.ws> wrote in message
news:46306533$1@newsgroups.borland.com...

> Is it possible to create a new process within (limited to) a given
> window of a running process - like for instance, Adobe Acrobat
> starting up to display a .pdf within Internet Explorer?

Acrobat implements an ActiveX control that IE loads to display pdf
files.  It does not load the main Acrobat application and then
position it inside the IE window.  The ActiveX control handles the
display internally.

> What I am hoping to do is to display files of different types from
an
> archive within the window of a vcl control, using their varying
display
> applications.

Unless those applications implement their own containable ActiveX
controls like Adobe does, then your only option is to start an
application, then manually find its window(s), such as with
EnumWindows() and GetWindowThreadProcessId() (use CreateProcess()
instead of ShellExecute() in order to get the thread and process IDs
of the application), and then use SetParent() to manually set them as
children for your own UI window.

> I have tried ShellExecute with the window parameter set to the
> handle of an existing control but this does not seem to help.

That is not what the hwnd parameter of ShellExecute() is for.


Gambit
Re: Start a Child Application in a Window
#2090
Author: David
Date: Wed, 02 May 2007 09:41
69 lines
3478 bytes
Remy,

Thanks. I have tried using EnumWindows() and GetWindowThreadProcessId() to 
enumerate all of the 'top level' threads/processes active on the workstation 
(a large number). However, none of these matches the thread or process ids 
returned by the CreateProcess(). Is it possible that the new process was 
created as a child of something? I was running the test from the IDE. If so, 
is there a better way than enumerating all the child processes of each top 
process?

Incidentally, had somewhat of a struggle to get the callback to 
EnumWindows() working. The first parameter of EnumWindows is a pointer to 
the callback routine which is defined as WNDENUMPROC, which in turn is 
defined as

     int __stdcall CbFunction ()

whereas the callback routine required is actually

     int __stdcall CbFunction (HWND w, LPARAM parm)

This means defining the latter and casting its pointer to the former when 
specifying the EnumWindows parameter - hardly sophisticated practice. Is 
this a bug in the header files or am I missing something obvious?

Regards,

David



"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:4630dd2e@newsgroups.borland.com...
>
> "David" <david@pedley.ws> wrote in message
> news:46306533$1@newsgroups.borland.com...
>
>> Is it possible to create a new process within (limited to) a given
>> window of a running process - like for instance, Adobe Acrobat
>> starting up to display a .pdf within Internet Explorer?
>
> Acrobat implements an ActiveX control that IE loads to display pdf
> files.  It does not load the main Acrobat application and then
> position it inside the IE window.  The ActiveX control handles the
> display internally.
>
>> What I am hoping to do is to display files of different types from
> an
>> archive within the window of a vcl control, using their varying
> display
>> applications.
>
> Unless those applications implement their own containable ActiveX
> controls like Adobe does, then your only option is to start an
> application, then manually find its window(s), such as with
> EnumWindows() and GetWindowThreadProcessId() (use CreateProcess()
> instead of ShellExecute() in order to get the thread and process IDs
> of the application), and then use SetParent() to manually set them as
> children for your own UI window.
>
>> I have tried ShellExecute with the window parameter set to the
>> handle of an existing control but this does not seem to help.
>
> That is not what the hwnd parameter of ShellExecute() is for.
>
>
> Gambit
>
> 
Re: Start a Child Application in a Window
#1997
Author: Remy Lebeau (TeamB)
Date: Wed, 02 May 2007 17:00
50 lines
2504 bytes
"David" <david@pedley.ws> wrote in message
news:46385cda$1@newsgroups.borland.com...

> I have tried using EnumWindows() and GetWindowThreadProcessId()
> to enumerate all of the 'top level' threads/processes active on the
workstation
> (a large number). However, none of these matches the thread or
process ids
> returned by the CreateProcess().

Yes, they will.  Please show your actual code.  I would also suggest
calling WaitForInputIdle() before calling EnumWindows(), to give the
new process some time to create and show its windows.

> Is it possible that the new process was created as a child of
something?
> I was running the test from the IDE.

No.  That wouldn't matter anyway, since you have the IDs of the new
process itself.  Each window belongs to a specific process, even if it
were a child process.

> Incidentally, had somewhat of a struggle to get the callback to
> EnumWindows() working. The first parameter of EnumWindows
> is a pointer to the callback routine which is defined as
> WNDENUMPROC, which in turn is defined as
>
>      int __stdcall CbFunction ()
>
> whereas the callback routine required is actually
>
>      int __stdcall CbFunction (HWND w, LPARAM parm)
>
> This means defining the latter and casting its pointer to the former
> when specifying the EnumWindows parameter

Yes.

> hardly sophisticated practice.

No, but it is required practice in this particular case.  Just one of
many quirks in how the Win32 API operates in general.

> Is this a bug in the header files

No.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads