OCX in web page

when i creat my own ocx by Vb and compilet it
than i use it in wab page and when i try to brows my
page appear to me (there is activex with be running are you sure you want to contino).
how i can make my own ocx or activex safty.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Dave_GreeneConnect With a Mentor Commented:
Ok, here is the step by step example.

1) Create an OCX Project (ActiveX Control)
2) right click your control, select add UserControl, then when you get into the VB dialog where you

normally select a usercontrol, select the wizard.
3) Add the Property you want to expose eg (Message) "My Custom Members" in the wizard
4) doesn't map to a control
5) When you get to the set attributes page, set Message to a string.

Your New Control Should Look Like this


'Default Property Values:
Const m_def_Message = "Empty Message"
'Property Variables:
Dim m_Message As String
'Event Declarations:

'MemberInfo=13,0,0,Empty Message
Public Property Get Message() As String
Message = m_Message
End Property

Public Property Let Message(ByVal New_Message As String)
m_Message = New_Message
PropertyChanged "Message"
MsgBox "Here is the Message you passed [" & m_Message & "]"
End Property

'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
m_Message = m_def_Message
End Sub

'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
m_Message = PropBag.ReadProperty("Message", m_def_Message)
End Sub

'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Message", m_Message, m_def_Message)
End Sub


6) Build your OCX
7) set binary compatibility on the control in the projects properties.
8) Add a standard EXE to your project group
9) Place the Control onto form1.
10) Check to see if the value you set in the controls property page (on form1) actually change the value,

if so proceed.

If not, it's time to write a comment on EE stating so. (listing the control code)
11) it worked!  yahoo!  Now build your OCX again just to be certain you have any changes
12) Use the Package and Deployment wizard to build the deployment
- Using the "Internet Package" option
- Take the defaults until you get to the "Safety Settings" tab, you will select "NO" for Safe for

Scripting, and

"YES" for safe for initialization.
- Now you are finished... with this step
13) now look into the directory where you built the package. you should see projectName.htm, open it

It should look something like this


<!--     If any of the controls on this page require licensing, you must
 create a license package file. Run LPK_TOOL.EXE to create the
 required LPK file. LPK_TOOL.EXE can be found on the ActiveX SDK,
 http://www.microsoft.com/intdev/sdk/sdk.htm. If you have the Visual
 Basic 6.0 CD, it can also be found in the \Tools\LPK_TOOL directory.

 The following is an example of the Object tag:

<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">

<OBJECT ID="UserControl1"


14) Make the following changes (per this example)
   <OBJECT ID="UserControl1" Height="400" Width="400"  <--however big the control is
    param name="Message" value="Your New Message here!"
15) Save your changes and run the projectname.htm
16) If it works great, if not... time to comment again  :)
hello issamtaher,
    First you need to create a .cab file by including your Ocx file by using Package and Deployment Wizard or by using Wise Set up, then write your code to display that ActiveX control in Html page or ASP page by using Object tag. So what will this do is when ever you are about to view your ASP page or HTML page which has your ocx Control first your browser will see whether you have that particular ocx in the client system if not it will download that ocx file from the WebServer and it will register in the system then that ocx control will be shown to the user over the browser.
    I have tried this for the Scroll bar control. Here i am sending you the code it may help you
<OBJECT CLASSID="clsid:79176FB0-B7F2-11CE-97EF-00AA006D2776" ID="spnTest" CODEBASE="../controls/ActivxCtr.cab" VIEWASTEXT>

There are several ways to fix this problem.  All of them have their short commings:

1) You can change the browser security settings to allow the .ocx to load without issueing a warning.

2) You can register the control as Web Safe (but should be done if it is truely websafe!) See MSDN for details.

3) You can build a distribution .cab file marking it websafe as previously mentioned.

4) You can use code in the .ocx to mark it safe for scripting and initialization.

5) You can licience your control and reference the licience directly in your HTML.

My suggestion - search MSDN and pick from the various options that best meet your needs.

I ran into this very problem a couple months ago and ended up writing my control in C++ using ATL.  Admittedly, it was a pretty radical solution but I chose it because it was so well documented by Microsoft.

Good luck.
Hi issamtaher,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Dave_Greene's comment(s) as an answer.

issamtaher, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer
Comment from expert accepted as answer

E-E Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.