borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Phone Dialler)Next Topic (Launching activex exe from web and accessing it ?) New Topic New Poll Post Reply
AndreaVB Forum : ActiveX : Multiple DLL's
Poster Message
arun_bm
Level: Guest


icon Multiple DLL's

I got a stand alone EXE File and two DLL's.

DLL 1 has an Instance variable called testVariable.

The EXE file has referenced both DLL's

DLL 2 has a Form and a text box in it.

This is the required sequence.

1) On form_load of exe cDLL1.testVariable is set to 3
2) Now I launch the form associated with DLL2
3) On form_load of this form I want the value of the testVariable to be displayed in the textBox

Any help is appreciated..

18-03-2004 at 10:33 AM
| Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 891
icon Re: Multiple DLL's

Hi,
I don't see the issue. You have already figured out how to set a variable in a dll, so expand the idea.. as in:

You should already have a public class in DLL2, so add a property called testVariable.
When the EXE launches DLL2, set the property (objDll2PublicClass.testVariable = objDLL1PublicClass.testVariable)
When DLL2 shows the form, set the textbox.value = testVariable in the public class.

Example:
DLL1:
Class clsDLL1
  public testVariable as string
end class
DLL2
Class clsDLL2
  public testVariable as string
  public sub ShowForm()
    dim frm as frmMain
    set frm=new frmMain
    frm.textbox1 = me.testVariable
    frm.Show
    unload frm
    set frm=nothing
  end sub
end class
EXE
sub Main
  dim objDLL1 as new clsDLL1
  dim objDLL2 as new clsDLL2

  objDLL1.testVariable = "fred"
  objDLL2.testVariable = objDLL1.testVariable
  objDLL2.ShowForm

  set objDLL1 = nothing
  set objDLL2 = nothing
end sub


I may be missing the point, however. Did you want the DLL2 to automatically show the value from DLL1 without the EXE setting it? If so, you have a couple of options:
1. Add the form to DLL1 instead of DLL2 and use DLL1 to hold the testVariable value in a global variable.
2. Add the ShowForm method to your class in DLL1, which can then set the variable.
3. Use an ActiveX EXE to hold the shared information - see the MSDN on creating singleton ActiveX exe's in VB.

General information on Singleton ActiveX EXEs.
Create an ActiveX EXE project.
Add a module called mdlGlobals
  Add a public variable g_Server as clsServer
  Add a public variable g_lngClientCount as long

Add a class called clsServer
  set properties to Public / Non-Creatable

Add a class called clsClient
  set properties to Public / Multi-Use
  add a class_Initialize and Terminate as below
private sub class_initialize
  if g_lngClientCount=0 then
    set g_Server = new clsServer
  end if
  g_lngClientCount = g_lngClientCount + 1
end sub
private sub class_terminate
  g_lngClientCount = g_lngClientCount - 1
  if g_lngClientCount<=0 then
    set g_server = nothing
  end if
end sub

Compile this EXE.
Reference this EXE from all DLLs that you wish to share data.
Each DLL creates as many instances of clsClient that they wish, however, only 1 instance of clsServer will ever be created. Add any properties you wish to share clsServer and expose them via clsClient:
ie.
in clsServer
private m_strTestVariable as string

public property let TestVariable(RHS as string)
  m_strTestVariable = RHS
end property
public property get TestVariable() as string
  TestVariable = m_strTestVariable
end property

in clsClient

public property let TestVariable(RHS as string)
  g_Server.TestVariable = RHS
end property
public property get TestVariable() as string
  TestVariable = g_Server.TestVariable
end property

and so on...

Hope this helps,
Kieron


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

19-03-2004 at 02:27 PM
View Profile Send Email to User Show All Posts | Quote Reply
arun_bm
Level: Guest

icon Re: Multiple DLL's

Thanks dude for the Single EXE Explanation...

It worked like a gem..

YOU ARE A LIFE SAVER....

26-03-2004 at 08:05 AM
| Quote Reply
AndreaVB Forum : ActiveX : Multiple DLL's
Previous Topic (Phone Dialler)Next Topic (Launching activex exe from web and accessing it ?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder