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

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
N

Nicholas Paldino [.NET/C# MVP]

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top