Solved

Get a Form from an ActiveX DLL

Posted on 2003-11-19
13
351 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Use closed file on desktop in vba 6 57
VB6 add a minute to the date time value 8 45
using Access 8 52
Spell Check in VB6 13 45
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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