468,765 Members | 944 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Ideas on "hooking" C# app as child to VB6?

I was wondering if someone has had a similar situation. We have a legacy VB6
application that is fairly large. We'd like to write new code in C# and have
it launched from the VB6 application so it looks, at least, like a child
module. We looked at seeing if we could host a C# control as an ActiveX
control and found that wouldn't work and it was an unsupported "feature". So
we are looking at just "shelling" from VB6 to the C# applicatoin and sending
it the minimal info it needs through command arguments. This works. We can
launch the application. Question comes in, when the "parent" (the VB6
applicaiton) is shut down, how can we enforce a shutdown of the C#
applicaiton? Further complicating this is that multiple "sessions" can be
launched of the VB 6 app, so we're really talking about the window that
launched the C# app, not the applicaiton name itself.

I'd rather not get into something hokey like writing a file out that says
"I'm closed" and having that notify the C# app (plus we'd have to register
the Hwnd to make sure and how would we differentiate different files -- how
do you cleanup the files when you're all done? etc.)

Would love to do some windows messaging, but not finding a lot to help
exactly. This is a client applicaiton written in VB6, trying to "talk" to a
C# applicaiton on the same machine. It would be nice to just broadcast a
message out from the parent that it's shutting down and have the C# app
respond to that message. Is that possible?

What other options are there to do this elegantly?

Todd
Nov 17 '05 #1
1 1368
Todd,

What I would do is in the VB6 app, call RegisterWindowsMessage, creating
a custom message for your partiular app's shutdown. You would also call
this in the .NET apps.

Then, when your VB6 app shuts down, you can call SendMessage (through
the API), passing HWND_BROADCAST as your window handle (you can get the
value from WinUser.h). Then, you override the WndProc method on your main
form in your .NET applications. When the message is the value returned from
RegisterWindowMessage, call Close on yourself, and your app will shut down.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Todd" <To**@REMOVEcprops.com> wrote in message
news:11*************@corp.supernews.com...
I was wondering if someone has had a similar situation. We have a legacy
VB6
application that is fairly large. We'd like to write new code in C# and
have
it launched from the VB6 application so it looks, at least, like a child
module. We looked at seeing if we could host a C# control as an ActiveX
control and found that wouldn't work and it was an unsupported "feature".
So
we are looking at just "shelling" from VB6 to the C# applicatoin and
sending
it the minimal info it needs through command arguments. This works. We can
launch the application. Question comes in, when the "parent" (the VB6
applicaiton) is shut down, how can we enforce a shutdown of the C#
applicaiton? Further complicating this is that multiple "sessions" can be
launched of the VB 6 app, so we're really talking about the window that
launched the C# app, not the applicaiton name itself.

I'd rather not get into something hokey like writing a file out that says
"I'm closed" and having that notify the C# app (plus we'd have to register
the Hwnd to make sure and how would we differentiate different files --
how
do you cleanup the files when you're all done? etc.)

Would love to do some windows messaging, but not finding a lot to help
exactly. This is a client applicaiton written in VB6, trying to "talk" to
a
C# applicaiton on the same machine. It would be nice to just broadcast a
message out from the parent that it's shutting down and have the C# app
respond to that message. Is that possible?

What other options are there to do this elegantly?

Todd

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Lars Netzel | last post: by
3 posts views Thread by sloan | last post: by
1 post views Thread by Peter Rilling | last post: by
8 posts views Thread by Jack Brown | last post: by
22 posts views Thread by ZioMiP | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.