473,378 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Referencing an ActiveX control in VB.NET

I have an ActiveX control that I would like to make available from any form
in my application. I figured the best way was to create a reference to it,
and then have a module that will create the instince and assign all of the
properties to the control. This is a control that I did not write, it was
purchased from a vendor. Here is what I have done.

In the references section of my project I have added the ocx.
I then go to a code module, and declare a variable and assign it to the
control reference, along with the class that it has available (through
intellisence)
However, when I try to instantiate the control the class is not available in
intellisense, only an interface and another class that isn't relevant to
what I am doing.

If I use this control on a form, it works fine. However, I wan't the form
to be allowed to be closed.
The control uses the comm port, so I don't want to have to manage opening
and closing the control on each form.
The only other solution I can think of is to have a hidden form that has the
control on it.

I have found some documentation on msdn that talks about using Tlbimp, but
it states that I have to be the author of the control to make it work.

Am I barking up the wrong tree here, and going in the wrong direction, or is
what I am trying to do possible.

TIA
Ken Breit
Nov 20 '05 #1
6 3410
Look in your windows Forms Desinger Generated code for the instance
reference of the active x control...

copy that code to your module...

=)
"Ken Breit" <kd********@ascentmedianospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have an ActiveX control that I would like to make available from any form in my application. I figured the best way was to create a reference to it, and then have a module that will create the instince and assign all of the
properties to the control. This is a control that I did not write, it was purchased from a vendor. Here is what I have done.

In the references section of my project I have added the ocx.
I then go to a code module, and declare a variable and assign it to the
control reference, along with the class that it has available (through
intellisence)
However, when I try to instantiate the control the class is not available in intellisense, only an interface and another class that isn't relevant to
what I am doing.

If I use this control on a form, it works fine. However, I wan't the form
to be allowed to be closed.
The control uses the comm port, so I don't want to have to manage opening
and closing the control on each form.
The only other solution I can think of is to have a hidden form that has the control on it.

I have found some documentation on msdn that talks about using Tlbimp, but
it states that I have to be the author of the control to make it work.

Am I barking up the wrong tree here, and going in the wrong direction, or is what I am trying to do possible.

TIA
Ken Breit

Nov 20 '05 #2
Thanks, that worked great. I actually had to add the control to the form,
and then it created the references for me. No that the dll is crated I will
just be able to add it to any project.

Thanks,
Ken
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
Look in your windows Forms Desinger Generated code for the instance
reference of the active x control...

copy that code to your module...

=)
"Ken Breit" <kd********@ascentmedianospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have an ActiveX control that I would like to make available from any form
in my application. I figured the best way was to create a reference to

it,
and then have a module that will create the instince and assign all of the properties to the control. This is a control that I did not write, it

was
purchased from a vendor. Here is what I have done.

In the references section of my project I have added the ocx.
I then go to a code module, and declare a variable and assign it to the
control reference, along with the class that it has available (through
intellisence)
However, when I try to instantiate the control the class is not available in
intellisense, only an interface and another class that isn't relevant to
what I am doing.

If I use this control on a form, it works fine. However, I wan't the
form to be allowed to be closed.
The control uses the comm port, so I don't want to have to manage opening and closing the control on each form.
The only other solution I can think of is to have a hidden form that has

the
control on it.

I have found some documentation on msdn that talks about using Tlbimp, but it states that I have to be the author of the control to make it work.

Am I barking up the wrong tree here, and going in the wrong direction,

or is
what I am trying to do possible.

TIA
Ken Breit


Nov 20 '05 #3
As always, happy to help. =)

"Ken Breit" <kd********@ascentmedianospam.com> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl...
Thanks, that worked great. I actually had to add the control to the form,
and then it created the references for me. No that the dll is crated I will just be able to add it to any project.

Thanks,
Ken
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
Look in your windows Forms Desinger Generated code for the instance
reference of the active x control...

copy that code to your module...

=)
"Ken Breit" <kd********@ascentmedianospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have an ActiveX control that I would like to make available from any

form
in my application. I figured the best way was to create a reference to
it,
and then have a module that will create the instince and assign all of the properties to the control. This is a control that I did not write,
it
was
purchased from a vendor. Here is what I have done.

In the references section of my project I have added the ocx.
I then go to a code module, and declare a variable and assign it to
the control reference, along with the class that it has available (through
intellisence)
However, when I try to instantiate the control the class is not

available
in
intellisense, only an interface and another class that isn't relevant to what I am doing.

If I use this control on a form, it works fine. However, I wan't the

form to be allowed to be closed.
The control uses the comm port, so I don't want to have to manage opening and closing the control on each form.
The only other solution I can think of is to have a hidden form that
has the
control on it.

I have found some documentation on msdn that talks about using Tlbimp,

but it states that I have to be the author of the control to make it work.

Am I barking up the wrong tree here, and going in the wrong direction,

or
is
what I am trying to do possible.

TIA
Ken Breit



Nov 20 '05 #4
Oops. Now when I try to use it when it is not on a form, I get an unhandled
exception error (InvalidActiveXStateException) when I try to assign a
property.
Do I have to do something to put the control in a paticular state. In
looking in the form designer code it there are a number of properties that
get assigned, but are not available, such as ocxstate. I am able to assign
the enable property a value, but when I try to assign a property such as
comm port, it comes back with the error. Any ideas?

Thanks,
Ken


"Ken Breit" <kd********@ascentmedianospam.com> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl...
Thanks, that worked great. I actually had to add the control to the form,
and then it created the references for me. No that the dll is crated I will just be able to add it to any project.

Thanks,
Ken
"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
Look in your windows Forms Desinger Generated code for the instance
reference of the active x control...

copy that code to your module...

=)
"Ken Breit" <kd********@ascentmedianospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have an ActiveX control that I would like to make available from any

form
in my application. I figured the best way was to create a reference to
it,
and then have a module that will create the instince and assign all of the properties to the control. This is a control that I did not write,
it
was
purchased from a vendor. Here is what I have done.

In the references section of my project I have added the ocx.
I then go to a code module, and declare a variable and assign it to
the control reference, along with the class that it has available (through
intellisence)
However, when I try to instantiate the control the class is not

available
in
intellisense, only an interface and another class that isn't relevant to what I am doing.

If I use this control on a form, it works fine. However, I wan't the

form to be allowed to be closed.
The control uses the comm port, so I don't want to have to manage opening and closing the control on each form.
The only other solution I can think of is to have a hidden form that
has the
control on it.

I have found some documentation on msdn that talks about using Tlbimp,

but it states that I have to be the author of the control to make it work.

Am I barking up the wrong tree here, and going in the wrong direction,

or
is
what I am trying to do possible.

TIA
Ken Breit



Nov 20 '05 #5
Hi,

It has to be sited on a form to reference it. The form DOES NOT have to be
displayed. This is "by design," AFAIK.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
Nov 20 '05 #6
Thanks.

PS - loved your book

"Dick Grier" <di**************@msn.com> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...
Hi,

It has to be sited on a form to reference it. The form DOES NOT have to be displayed. This is "by design," AFAIK.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
2
by: Fie Fie Niles | last post by:
This one XP machine (with IE 6) is having a problem viewing any ActiveX controls (created on VB6) on the Internet Explorer browser. I put the same ActiveX control in a VB program, and when I run...
3
by: Michiel | last post by:
Hello, I have an ActiveX control which I can call fine from HTML pages, using the object tag like <OBJECT ID="UserControl1" WIDTH="0" HEIGHT="0"...
3
by: Jeffery Franzen | last post by:
Anyone know where the documentation is regarding Activex controls in asp web forms? I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app. I do the add...
0
by: Ken Breit | last post by:
I have an ActiveX control that I would like to make available from any form in my application. I figured the best way was to create a reference to it, and then have a module that will create the...
0
by: Frank | last post by:
I am attempting to convert an asp file to a asp.net file using C#. The original file has an ActiveX control which is contained in a cab file. The cab file contains the .ocx file which connects...
7
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do...
1
by: Jako | last post by:
Hi guys... Well once again I'm in a dilemma. Currently I have a RTF2 object in Access that is linked to a memo field in a table, the reason for this is so that I can have bullets and numbers in...
6
by: hufaunder | last post by:
I have an ActiveX component that I want to use in a library that I am writing. As a first test I used the ActiveX component in a windows form application. Adding the component created: Ax.dll...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.