BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Start a Child Application in a Window

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
David
Guest





PostPosted: Thu Apr 26, 2007 1:39 pm    Post subject: Start a Child Application in a Window Reply with quote



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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Apr 26, 2007 10:08 pm    Post subject: Re: Start a Child Application in a Window Reply with quote



"David" <david (AT) pedley (DOT) ws> wrote in message
news:46306533$1 (AT) newsgroups (DOT) borland.com...

Quote:
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.

Quote:
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.

Quote:
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
Back to top
David
Guest





PostPosted: Wed May 02, 2007 2:41 pm    Post subject: Re: Start a Child Application in a Window Reply with quote



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 (AT) no (DOT) spam.com> wrote in message
news:4630dd2e (AT) newsgroups (DOT) borland.com...
Quote:

"David" <david (AT) pedley (DOT) ws> wrote in message
news:46306533$1 (AT) newsgroups (DOT) 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

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed May 02, 2007 10:00 pm    Post subject: Re: Start a Child Application in a Window Reply with quote

"David" <david (AT) pedley (DOT) ws> wrote in message
news:46385cda$1 (AT) newsgroups (DOT) borland.com...

Quote:
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.

Quote:
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.

Quote:
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.

Quote:
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.

Quote:
Is this a bug in the header files

No.


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.