[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need help creating an ActiveX Dll from a class

Posted on 2002-05-11
28
Medium Priority
?
172 Views
Last Modified: 2013-11-23
I need help creating an ActiveX Dll from the class posted below. Each time I try to compile the Dll, I get the following message error "No creatable public component detected." Also, after you create the DLL, could you create a sample project using the DLL in a standard exe?

Class:

Option Explicit

' The PictureBox we draw on.
Public picCanvas As PictureBox

' The rectangle's drawing attributes.
Public X0 As Single
Public Y0 As Single
Public Radius As Single
Public DrawWidth As Integer
Public ForeColor As OLE_COLOR
Public FillColor As OLE_COLOR
Public FillStyle As FillStyleConstants
Public DrawStyle As DrawStyleConstants

' Default property values.
Private Const m_def_X0 = 0
Private Const m_def_Y0 = 0
Private Const m_def_Radius = 80
Private Const m_def_DrawWidth = 1
Private Const m_def_ForeColor = vbBlack
Private Const m_def_FillColor = vbBlack
Private Const m_def_FillStyle = vbBlack
Private Const m_def_DrawStyle = vbSolid

' Draw on picCanvas.
Public Sub Draw()

   Form1.Picture1.ForeColor = ForeColor
   ' Set other drawing attributes.
   With fmyform(iCurrentProcId).picCanvas
       .FillStyle = FillStyle
       .FillColor = FillColor
       .DrawWidth = DrawWidth
       .DrawStyle = DrawStyle
   End With

   ' Draw the object.
   Form1.Picture1.Circle (X0, Y0), Radius, Form1.Picture1.ForeColor
End Sub

' Set default property values.
Private Sub SetDefaultProperties()
   X0 = m_def_Y0
   Y0 = m_def_X0
   Radius = m_def_Radius
   DrawWidth = m_def_DrawWidth
   ForeColor = m_def_ForeColor
   FillColor = m_def_FillColor
   FillStyle = m_def_FillStyle
   DrawStyle = m_def_DrawStyle
End Sub

' Set some defaults.
Private Sub Class_Initialize()
   SetDefaultProperties
End Sub
0
Comment
Question by:Gmoney
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 8
  • 7
28 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7003866
Try setting Instance property to 5-multiuse.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7003869
Where are those form and picture box, in a form?
If so, how class know about them. I cannot see any "connection"  between class module and form.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7003871
Besides, using public variables to simulate properties doesn't help you. It only gives you troubles.
In background, VB creates them anyway.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Gmoney
ID: 7003914
setting the Instance property to 5-multiuse helped some but I'm still receiving compile errors.
0
 

Author Comment

by:Gmoney
ID: 7004002
setting the Instance property to 5-multiuse helped some but I'm still receiving compile errors.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7004414
the same error or a new one?
0
 

Author Comment

by:Gmoney
ID: 7004534
could someone copy the class, compile it into a dll, and email it to me in an example of using it?

emoreau, i'm getting different errors
0
 

Author Comment

by:Gmoney
ID: 7004575
i got the DLL compiled, now all i need is an example of how to call the DLL in a standard exe project.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7004782
You need to set a reference to that library in your standard exe and create a variable of its type (just like any other COM class):
i.e.

dim objMydll as MyActiveXDll

and from it, maybe you need to create a new one:
set objMydll = new MyActiveXDll.myclass

and you would be ready to use properties/methods from it.

That's a generic approach, you have to know the rest.Hope it helps
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7004996
You will need another public property into your class: fMyForm.
0
 

Author Comment

by:Gmoney
ID: 7005029
Richie could you please create an example project?
0
 

Author Comment

by:Gmoney
ID: 7005088
I still need a lot of help on this
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 600 total points
ID: 7005598
I have change this method of your class:

Public Sub Draw(ByRef fMyForm As Object)

  fMyForm.Picture1.ForeColor = ForeColor
  ' Set other drawing attributes.
  With fMyForm.picCanvas
      .FillStyle = FillStyle
      .FillColor = FillColor
      .DrawWidth = DrawWidth
      .DrawStyle = DrawStyle
  End With

  ' Draw the object.
  fMyForm.Picture1.Circle (X0, Y0), Radius, fMyForm.Picture1.ForeColor
End Sub

And I places this into a new standard EXE after having added a command button (command1), 2 picture box (picture1 and piccanvas) and after having set a reference to your DLL.

Option Explicit

Private Sub Command1_Click()
Dim x As Project1.Class1

    Set x = New Project1.Class1
    With x
        .X0 = 1000
        .Y0 = 1000
        .ForeColor = vbBlack
        .FillColor = vbRed
        .Radius = 500
        .Draw Me
    End With
End Sub
0
 

Author Comment

by:Gmoney
ID: 7006152
How do I set reference to the DLL emoreau
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7006161
project -> references and then find your component into the displayed list.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7006203
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7006225
Could explain a little more where do you get the error. All is posting the same comments but...
0
 

Author Comment

by:Gmoney
ID: 7006425
emoreau mcdonald_g is my brother, we are working on the same problem
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7006545
Did you work with active x dll before?
I mean, automating excel or word, or using FileSystem objects?
If so, you have to use the same approach with your own dll.
0
 

Author Comment

by:Gmoney
ID: 7006703
emoreau, what code do I put in the declarations part of the form?
0
 

Author Comment

by:Gmoney
ID: 7006718
emoreau, your all most there, just give me the complete code to implement the Dll in a standard exe.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7006731
I already posted it in a previous post:

Option Explicit

Private Sub Command1_Click()
Dim x As Project1.Class1

   Set x = New Project1.Class1
   With x
       .X0 = 1000
       .Y0 = 1000
       .ForeColor = vbBlack
       .FillColor = vbRed
       .Radius = 500
       .Draw Me
   End With
End Sub


Are you missing something?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7006759
As i posted previously:
'general declarations section of form
dim objMydll as MyActiveXDll

'In sub form_load event
set objMydll = new MyActiveXDll.myclass
'start using methods/properties from here
end sub
0
 

Author Comment

by:Gmoney
ID: 7007301
Could someone email me sample project of the Dll and Exe at glynn.mcdonald@charter.net and I will post you the points. I followed the above directions and still got errors!
0
 

Author Comment

by:Gmoney
ID: 7007312
Someone please email me tonite, I need this for a project that I suppose to email my boss today.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7007447
which errors?
0
 

Author Comment

by:Gmoney
ID: 7007476
Thanks a bunch
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7007481
will you convince your brother to accept the other question to me too?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

649 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