Solved

Get a Form from an ActiveX DLL

Posted on 2003-11-19
13
355 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 84
Excel - Save a copy of work book 13 91
Crystal reports - Formula Field code need assistance with code 17 92
Dinamic report to Crosstab query 9 52
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 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