Solved

Get a Form from an ActiveX DLL

Posted on 2003-11-19
13
352 Views
Last Modified: 2010-05-03
Hi,

I'd like to know if I can retrieve a form from an ActiveX component.

I am testing a component that allows me to "include" a form inside another form. The function that does so needs the reference to the form that should be included.

Eg.  the function would be

       asComponent.SubForm frmIncludedForm

where frmIncludedForm is the form I want to include.

The problem is that the form i want to include is in an ActiveX DLL. I have tried to use Property Get to retrieve the form but it says that I can't return a private object as a parameter of a public function.

Any idea?

pablo


0
Comment
Question by:pablete
  • 6
  • 3
  • 2
  • +2
13 Comments
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9777218
use your public function to call a private one, seems redundandt but it might work???
0
 
LVL 29

Expert Comment

by:Nightman
ID: 9777493
Forms are private.

You cannot return the form instance from one ActiveX.dll to another. Instead, it would probably be easier to create a ShowForm sub in the other dll which then displays it's own form.

Cheers
Night
0
 
LVL 1

Expert Comment

by:c2felicia
ID: 9778913
I tried before with your case. The ActiveX DLL will be added in your project if you clicked the "Add Standard EXE Project" button that inside the tool bar there. The ActiveX DLL will be added in project, not form, but it still work while execute your project forms.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
ID: 9778928
Why not?


Try this
on your dll, add text box on your form


Option Explicit

Private Myform As New Form1

Public Function getform() As Object
Set getform = Myform

End Function


On your standard exe, add 2 buttons

Option Explicit
Private cls1 As Object
Private myform As Object
Private Sub Command1_Click()
Set cls1 = CreateObject("Project1.Class1")
Set myform = cls1.getform
myform.Show
End Sub

Private Sub Command2_Click()
myform.Text1 = Now
End Sub

0
 
LVL 1

Expert Comment

by:c2felicia
ID: 9778943
if you have existing ActiveX DLL, make sure you have added in your project that you want it to execute with your forms. Because we cannot open or add another project into the project. we all known that we only can add forms, modules, ActiveX DLL, User Control........ without a project.
0
 

Author Comment

by:pablete
ID: 9779872
EDDYKT, Have you really tried the solution you suggested? It is completely opposed to the answer that Nightman suggested...

pablo
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 26

Expert Comment

by:EDDYKT
ID: 9779924
Have you tried?

It works here
0
 

Author Comment

by:pablete
ID: 9780128
Hey EDDYKT, it does work. but, how can be possible? I read from msdn:

"The dialog box is not invoked directly from the client, because forms are private classes. Clients cannot create instances of private classes, and you should never pass instances of private classes to client applications.!

That is what Nightman said...

I am bit lost in this. I am about to give you the points, EDDYKT, but I will split them with somebody who helps me with this contradiction.

Pablo
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9780178
What doesn't work?

Which line cause the problem?
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9780195
The way I do is pass the object from dll to standard exe


When you do that

Private Sub Command2_Click()
myform.Text1 = Now
End Sub


you can see the textbox contain has been changed.
0
 

Author Comment

by:pablete
ID: 9780642
EDDYKT, you are right. I said that it works, but i don't understand the reason... I'll keep this question open till tomorrow waiting for an explanation and then i'll give you the points
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9780874
I don't understand what do you don't understand

This is just OLE object pass to container.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9781083
>>"The dialog box is not invoked directly from the client, because forms are private classes. Clients cannot create instances of private classes, and you should never pass instances of private classes to client applications.!


It is true, I did not create the form from container, I just pass the object to container. The form still create from dll. I just pt it out you still can access from container since dll is run as in-process
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now