473,394 Members | 1,802 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,394 software developers and data experts.

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 1463
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
2
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
4
by: Lars Netzel | last post by:
Is there any way to add some code that will happen in every single Event that i raised in a form? I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to...
3
by: sloan | last post by:
How does one "pass thru" a Raised Event.... I am using the Adapter Pattern to sync up some different interfaces. http://www.dofactory.com/Patterns/PatternAdapter.aspx My Question is this:
8
by: | last post by:
The New York Times and many other online publications automatically generate "most popular article" lists that cover, say, the last 24 hours. I am looking for guidance and/or code on the best way...
1
by: Peter Rilling | last post by:
Hi. I am using Atlas and hooking a load event using add_load(...). This is being called from the constructor of an object being created, so it is within the context of an object (where 'this'...
8
by: Jack Brown | last post by:
Hi there, I need to create a unique identifier for my own internal needs and am happy to rely on "Guid.NewGuid()" to pull this off. I'd like to know if .NET offers any competing alternative...
22
by: ZioMiP | last post by:
Hi to all... I'm actually using Tkinter for my GUI... but I need to "put a piece of a web-page in a widget" how can I do? which GUI module do you suggest me to use for do that? or which GUI...
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.