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 (Communicate between ActiveX forms & usercontrol????)Next Topic (Run-time Control Loading) New Topic New Poll Post Reply
AndreaVB Forum : ActiveX : ActiveX DLL
Poster Message
DavidG
Level: Guest


icon ActiveX DLL

Hi

Two Projects
Standard EXE
ActiveX DLL

I created a DLL File that places Pictureboxs, Commandbuttons etc... on a
form at runtime in the Standard EXE project.

When in IDE I am able to get events for each control in the Dll Class and
do something. (This works fine) when I compile the DLL file I no longer have
the events.

What do I need to do to get the events? SubClass?
-
I tried timer in the DLL
label1.caption = now
When I press F5 I get the time in the label fine compiled DLL nothing happens
-

Any help would be great

Thanks in advance
David

16-09-2002 at 07:55 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: ActiveX DLL

If you're wanting it to work in all programs in VB, it'd have to be made into a plugin. Otherwise a reference to the dll will have to be added to the exe program (which would be a lot easier, although can't say if it'd still work as you intend).

17-09-2002 at 01:26 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
DavidG
Level: Guest

icon Re: ActiveX DLL

The DLL in question is referenced...

Dim aa as clsAA

aa.Initialize Me 'Form

The DLL Add.Control (Pictureboxes etc...)

this is created OK, just missing the mouse over events within the DLL.

When in IDE the events are working just fine. It's when I compile to the DLL and reference it to a new project that the DLL events do not work.

Thanks for the Help
David

17-09-2002 at 01:43 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: ActiveX DLL

Unfortunetely I can't think of any solution offhand.

17-09-2002 at 08:04 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: ActiveX DLL

quote:
DavidG wrote:
The DLL in question is referenced...

Dim aa as clsAA

aa.Initialize Me 'Form

The DLL Add.Control (Pictureboxes etc...)

this is created OK, just missing the mouse over events within the DLL.

When in IDE the events are working just fine. It's when I compile to the DLL and reference it to a new project that the DLL events do not work.

Thanks for the Help
David


I know this is very old by now but I thought I would contribute something and maybe get this going again. From what I see DavidG is passing an instance of the form to the Initialize method in his .DLL.

Now a close look at the documentation tells that Forms and most controls are Private instancing objects and therefore cannot be exposed to outside programs.

So I can almost bet (I don't gamble but this is a good chance to win) that the declaration is something like this:

Public Sub Initialize(TargetForm As Object)

'or

Public Sub Initalize(TargetForm As Variant)


This was the only way you could pass such objects to the outside world and could work. However, this is also very discouraged and is not guaranteed to work all the time and at the time VB6 was the latest thing around, was not guaranteed to work in the future (meaning that existing code could just stop working).

I'm convinced that the behaviour DavidG was getting is because of this. It would be advisable to not do this. I personally never do. I write many dlls that interface closely with the windows my program has but I don't do it this way.

The  2 main ways I use and I would suggest are these
1 Subclassing and
2 Implementing an interface in the form

The interface will be defined in the Dll and the form will have to imlement it and pass itself as part of the interface. The Dll could then call back some methods on the form via this interface. This is type safe, guaranteed to work and uses early binding so any problems can be picked at compile time rather than waiting until the program has been running for a while.

Let me know if this was helpful and we could probably keep this going. Happy coding.

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer
03-02-2004 at 06:36 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
SurfzUp
Level: Guest

icon Re: ActiveX DLL

Following on from JL, I would use custom callback as JL mentioned via an interface. Have posted code not using interfaces that might answer problem,if I have understood problemcorrectly.

[Edited by SurfzUp on 23-02-2004 at 01:07 PM GMT]

____________________________
Attached:
TestFormevents.zip 3 KB (Downloads: 9)

12-02-2004 at 09:48 PM
| Quote Reply
AndreaVB Forum : ActiveX : ActiveX DLL
Previous Topic (Communicate between ActiveX forms & usercontrol????)Next Topic (Run-time Control Loading) 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