473,406 Members | 2,439 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,406 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 3416
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.