473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Another Programming Question

Hi everyone!

I am developing an application that runs a seperate executiblie file, calls
the SetParent API so the application is contained in my application.

The problem that I am having is I have to wait a certain period of time for
the application to completely run/load into memory before I can call the
SetParent api or it does nothing.

What's the best way to determine when an application is at a point to call
the SetParent API?

Thanks,

Y
Nov 16 '05 #1
7 3864
SetParent is used to change the parent window of a child window, does it
mean you are trying to change the parent of a child window of a launched
(child) application to a window in your launching (parent) application? If
this is what you want, forget about it, parent/child relationship for window
handles is bound to the same application.

Willy.
"Yoshi" <yo***@home.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
Hi everyone!

I am developing an application that runs a seperate executiblie file,
calls the SetParent API so the application is contained in my application.

The problem that I am having is I have to wait a certain period of time
for the application to completely run/load into memory before I can call
the SetParent api or it does nothing.

What's the best way to determine when an application is at a point to call
the SetParent API?

Thanks,

Y

Nov 16 '05 #2
Willy,

I have developed an application that launches a .exe program like "Excel."
My application gets the handle of this application and Sets Excel's parent
to my application of which it appears as if it's running my application.

The issue I am having is there's a point in which I need to call the
SetParent api for Excel to appear in my application. I have narrowed it down
to when the application has finished running. I am looking for a method to
wait for the application to finish loading so I can Set it's parent to my
application and see it running.

Thanks,

Y
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
SetParent is used to change the parent window of a child window, does it
mean you are trying to change the parent of a child window of a launched
(child) application to a window in your launching (parent) application? If
this is what you want, forget about it, parent/child relationship for
window handles is bound to the same application.

Willy.
"Yoshi" <yo***@home.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
Hi everyone!

I am developing an application that runs a seperate executiblie file,
calls the SetParent API so the application is contained in my
application.

The problem that I am having is I have to wait a certain period of time
for the application to completely run/load into memory before I can call
the SetParent api or it does nothing.

What's the best way to determine when an application is at a point to
call the SetParent API?

Thanks,

Y


Nov 16 '05 #3


"Yoshi" <yo***@home.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
Willy,

I have developed an application that launches a .exe program like "Excel."
My application gets the handle of this application and Sets Excel's parent
to my application of which it appears as if it's running my application.

The issue I am having is there's a point in which I need to call the
SetParent api for Excel to appear in my application. I have narrowed it
down to when the application has finished running. I am looking for a
method to wait for the application to finish loading so I can Set it's
parent to my application and see it running.

Please re-read my previous posting, this is not the purpose of SetParent.
Could you be more specific when talking about handles? When you say "My
application gets the handle ", I assume you are talking about the process
handle, not a window handle right?
Now what are you doing with this handle in relation to the SetParent API ?
A piece of code could say more than a thousand words I guess :-)

Willy.
Nov 16 '05 #4
Hey Willy...

Here is a quick example:

[DllImport("user32.dll")]

static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

System.Diagnostics.ProcessStartInfo si = new
System.Diagnostics.ProcessStartInfo();
si.FileName = "winword.exe";
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(si);
p.EnableRaisingEvents = true;

p.Exited += new EventHandler(OnHasExited);

SetParent(p.MainWindowHandle, this.Handle);

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...


"Yoshi" <yo***@home.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
Willy,

I have developed an application that launches a .exe program like
"Excel." My application gets the handle of this application and Sets
Excel's parent to my application of which it appears as if it's running
my application.

The issue I am having is there's a point in which I need to call the
SetParent api for Excel to appear in my application. I have narrowed it
down to when the application has finished running. I am looking for a
method to wait for the application to finish loading so I can Set it's
parent to my application and see it running.

Please re-read my previous posting, this is not the purpose of SetParent.
Could you be more specific when talking about handles? When you say "My
application gets the handle ", I assume you are talking about the process
handle, not a window handle right?
Now what are you doing with this handle in relation to the SetParent API ?
A piece of code could say more than a thousand words I guess :-)

Willy.

Nov 16 '05 #5

"Yoshi" <yo***@home.com> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
Hey Willy...

Here is a quick example:

[DllImport("user32.dll")]

static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

System.Diagnostics.ProcessStartInfo si = new
System.Diagnostics.ProcessStartInfo();
si.FileName = "winword.exe";
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(si);
p.EnableRaisingEvents = true;

p.Exited += new EventHandler(OnHasExited);

SetParent(p.MainWindowHandle, this.Handle);

You could use Process.WaitForInputIdle to make sure the process has started
and it's message loop is spinning.
BUT, as I said before what you are doing here :
SetParent(p.MainWindowHandle, this.Handle);
is wrong. SetParent takes two handles belonging to the same application, in
your case they belong to different applications. Did you ever checked the
return value? I guess you are not.
What exactly are you trying to achieve?

Willy.

Nov 16 '05 #6
I am developing an application that contains certain modules. There is an
external application that the user runs. I would like to run the application
but make it look like it's part of my application. It's basically contained
in my application.

The SetParent works but requires a "desired" pause so the external
application can load to a certain point for the SetParent to work properly.

Make sense now?

Thanks,

Y


"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:ey*************@TK2MSFTNGP14.phx.gbl...

"Yoshi" <yo***@home.com> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
Hey Willy...

Here is a quick example:

[DllImport("user32.dll")]

static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

System.Diagnostics.ProcessStartInfo si = new
System.Diagnostics.ProcessStartInfo();
si.FileName = "winword.exe";
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(si);
p.EnableRaisingEvents = true;

p.Exited += new EventHandler(OnHasExited);

SetParent(p.MainWindowHandle, this.Handle);

You could use Process.WaitForInputIdle to make sure the process has
started and it's message loop is spinning.
BUT, as I said before what you are doing here :
SetParent(p.MainWindowHandle, this.Handle);
is wrong. SetParent takes two handles belonging to the same application,
in your case they belong to different applications. Did you ever checked
the return value? I guess you are not.
What exactly are you trying to achieve?

Willy.

Nov 16 '05 #7

"Yoshi" <yo***@home.com> wrote in message
news:ul**************@tk2msftngp13.phx.gbl...
I am developing an application that contains certain modules. There is an
external application that the user runs. I would like to run the
application but make it look like it's part of my application. It's
basically contained in my application.

The SetParent works but requires a "desired" pause so the external
application can load to a certain point for the SetParent to work
properly.

Make sense now?


Here's what you can do, but again it's not supposed you do this, read the
remarks paragraph in the SetParent documentation on MSDN and you will see
both handles must belong to the same application. It's not because something
"seems" to work that it's correct to assume it will do all the time under
all circumstances.

if (p.WaitForInputIdle(10000)) // wait max. 10 sec's
SetParent(p.MainWindowHandle, this.Handle);

else

.... // something took to many time here

Willy.


Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: nospam | last post by:
THIS IS the DOTNETJUNKIES MESSAGE ------------------------- We're Sorry As many of you know we have recently launched SqlJunkies.com. We have overhauled our runtime and will be using it on...
19
by: Anon Email | last post by:
Hi everyone, Let's see, now. This question is about the capabilities of ANSI C++. I want to write and compile code in ANSI C++ that, when compiled, will make the computer speaker beep; or, at...
29
by: Tola | last post by:
In my case of study, my teacher gave me a project, after I analysed the problem I found that I had to used open the file on the other machine? Please help? Thank you in advance. Tola CHROUK
31
by: Christopher Benson-Manica | last post by:
How about your if/else if/else constructs? Being nitpicky like any good C programmer, I'm in the process of transforming code written like if( cond ) { ... } else if( some_other_cond ) {...
1
by: John Sheppard | last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand. Programming environment. VS.NET 2003, C#, Windows...
39
by: anonymous | last post by:
Dear All, >From my understanding of pointers, a pointer should not be able to access a memory location until that memory has been allocated either by assiging the address of a variable or...
24
by: David Mathog | last post by:
On a Solaris 8 system if a user "joe" logs in, for instance via ssh, cuserid() returns "joe". That's the expected behavior and so far so good. However if that user then does: % su - sally ...
24
by: =?Utf-8?B?RHIuIFMu?= | last post by:
I am incorporating three existing programs into a new "all in one" program. I have added the three projects to the new all in one project. How do I instruct the new initial menu to launch the main...
12
by: ciccio | last post by:
Hi, I was wondering why in the following piece of code, the function test1 calls a copy constructor at return and why test2 does not. Is the usage of multiple return statements in one function...
8
by: Markus | last post by:
Hello everyone. Recently I stumbled upon an interesting problem related to thread-parallel programming in C (and similarily C++). As an example assume a simple "buffer" array of size 8, e.g....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.