-
I have a huge project and it would be verry nice if I could split it into small pieces.
It is easy if I could do separate executables but my proj is MDI.
My first option was trying to make one activex dll for each form but I could not pass the form to the main prog.
Any sugestions?? Tks.
-
If you're looking for an example of cross application communication (passing info between EXE's) then here's an example I put together a while back this year.
It demonstrates the use of an ActiveX EXE (out of process server) to allow 2 or more external applications to connect to it and share data:
Create a new ActiveX EXE project:
Code:
'In a Standard Module..
'Global CommandLine Object
Public oCommandLine As CommandLine
'No. of Current Connections
Public lConnected As Long
Code:
'In a Class Module Called: Connector
'Instancing: 5 - MultiUse
'
Private Sub Class_Initialize()
'If the Global CommandLine Object isn't Initialized, then Initialize it
If oCommandLine Is Nothing Then
Set oCommandLine = New CommandLine
End If
'Increment the number of Connections to this Object
lConnected = lConnected + 1
End Sub
Private Sub Class_Terminate()
'Decrement the Number of Connections to this Object
lConnected = lConnected - 1
'If the No. of Connections is Zero, Destroy the Global
'Command Line Object, Releasing the ActiveX EXE
If lConnected = 0 Then Set oCommandLine = Nothing
End Sub
Public Property Get CommandLine() As CommandLine
'Return a Reference to the Global CommandLine Object
Set CommandLine = oCommandLine
End Property
Code:
'In a Class Module Called: CommandLine
'Instancing: 2 - PublicNotCreatable
'
Public Event Change()
Private sString As String
Public Property Get szString() As String
'Return the Value of the szString Property
szString = sString
End Property
Public Property Let szString(ByVal vNewValue As String)
'Set the Value of the szString Property and Trigger
'the Change Event
sString = vNewValue
RaiseEvent Change
End Property
Compile the Project into an EXE, call the ActiveX Project/EXE "AppExtender"
Create a Standard EXE Project:
Code:
'In a Standard Module:
'Create a Private Instance of the CommandLine Object
'So that we can still change the Commandline if
'we have to unload this Instance..
Private oCommandLine As AppExtender.CommandLine
'Create a Public Connector Object, used to get a
'Reference to the Globally Shared CommandLine Object..
Public oConnector As New AppExtender.Connector
Sub Main()
'Get the CommandLine Object..
Set oCommandLine = oConnector.CommandLine
'If this is the 1st Instance, show the Form
If Not App.PrevInstance Then Form1.Show
'Set the CommandLine Object's szString Property to
'this instances CommandLine, Triggering the Change
'Event of the CommandLine Object in the Other Instance.
oCommandLine.szString = Command
End Sub
Code:
'In a Form with a Textbox
'Create a Private Instance of the CommandLine Object with
'the Change Event, which will Trigger Each Time the szString
'Property of the CommandLine Object is Changed, in any App.
Private WithEvents oCommandLine As AppExtender.CommandLine
Private Sub Form_Load()
'Get the CommandLine Object from the Public Connector
Set oCommandLine = oConnector.CommandLine
End Sub
Private Sub oCommandLine_Change()
'Triggered when the value of szString changes
Text1 = oCommandLine.szString
End Sub
Set the Startup Object for the Project to "SubMain" and compile the Project into an EXE.
Now drag any file onto the EXE and the 1st time it will load the Form and display the dropped files name and path in the Textbox.
Leave the Form open and drag another file onto the EXE, this time instead of showing another Form, the new EXE passes the file name and path to the 1st instance of the program via the "AppExtender" ActiveX Server.
Hope this helps.
-
Good code
[QUOTE]Originally posted by Aaron Young
Hi Aaron,
Your code is verry good! But what I was trying to do is to have some sort of several Dlls so I could update small pieces of the program and send them separately.
For example supose I have one Exe file and 3 others Dll. I could update one Dll and send it to the user without having to send the Exe and the other 2 Dlls.
To make this possible the forms in one Dll should access the controls, data conn, etc of the main Exe program.
Is it possible?
Best,
André.
-
Aaron,
Just what I was looking for. I knew it could be done and messed around a little with no success. Your example was what I needed to keep me going.
Had I not been looking for it I would have had no clue what the code did.
Q: Is is possible to have the activex running on a central machine and have several programs connect with it? I am looking for a way to notify users of my program that things have changed so the program can react.
Thanks again for the sample.
-
Yes you could do that several ways; to use ActiveX in the manner I've described,
you would have to implement DCOM (Distributed COM), another option would be
to communicate over TCP/IP using something like Winsock;
it really depends on what your needs are.
Regards,
- Aaron.