Solved

Adding ActiveX Control to HTML-doc

Posted on 2001-06-27
16
231 Views
Last Modified: 2008-02-26
How do you add an ActiveX Control .ocx to a web page?
0
Comment
Question by:kristofer
  • 6
  • 6
  • 2
  • +2
16 Comments
 
LVL 1

Expert Comment

by:choroque
ID: 6230853
<object id="myid" classid="clsid:your class id" codebase="mycab.cab#Version=5,0,4,15">
<PARAM NAME="myparameter" VALUE="myvalue">
</object>

you can insert the object using ms frontpage or visual interdev. I believe your vb app have an .ocx
files. Just insert the .ocx files using frontpage or interdev (the classid will be automatically created),
then in the "codebase", refer to your cab file.
0
 
LVL 2

Author Comment

by:kristofer
ID: 6230861
Cab file? how do I get the cab file?? package and deployment wizard?
0
 
LVL 2

Author Comment

by:kristofer
ID: 6230871
#Version=5,0,4,15?? how do I know?
0
 
LVL 1

Expert Comment

by:choroque
ID: 6233576
actually, you can just use frontpage or visual interdev to insert the .ocx. Just forget about the cab file if you don't have one. About the version, it will be automatically inserted as you put the .ocx on you web page, just like the classid.
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6235715
Ok, here is the step by step example. USING VB

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

'CODE BEGIN

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

'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'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

'CODE END

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

'HTML BEGIN

<HTML>
<HEAD>
<TITLE>Project1.CAB</TITLE>
</HEAD>
<BODY>
<!--     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">
 <PARAM NAME="LPKPath" VALUE="LPKfilename.LPK">
</OBJECT>
-->

<OBJECT ID="UserControl1"
CLASSID="CLSID:291EACFF-517D-4B6C-9EF0-A329A541AD8C"
CODEBASE="Project1.CAB#version=1,0,0,0">
</OBJECT>
</BODY>
</HTML>

'HTML END

14) Make the following changes (per this example)
   <OBJECT ID="UserControl1" Height="400" Width="400"  <--however big the control is
 CLASSID="CLSID:291EACFF-517D-4B6C-9EF0-A329A541AD8C"
 CODEBASE="Project1.CAB#version=1,0,0,0">
    <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  :)

Cheers!  
0
 
LVL 1

Expert Comment

by:dluedi
ID: 6241169
Hi kristofer, If you've got Windows Mediaplayer here is an much easier example:
Just copy this and save it as e.x: test.htm



<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>This is an Activ-X Test</title>
</head>

<body>

<p>
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="MediaPlayer1" width="286" height="225">
  <param name="AudioStream" value="-1">
  <param name="AutoSize" value="-1">
  <param name="AutoStart" value="-1">
  <param name="AnimationAtStart" value="-1">
  <param name="AllowScan" value="-1">
  <param name="AllowChangeDisplaySize" value="-1">
  <param name="AutoRewind" value="0">
  <param name="Balance" value="0">
  <param name="BaseURL" value>
  <param name="BufferingTime" value="5">
  <param name="CaptioningID" value>
  <param name="ClickToPlay" value="-1">
  <param name="CursorType" value="0">
  <param name="CurrentPosition" value="-1">
  <param name="CurrentMarker" value="0">
  <param name="DefaultFrame" value>
  <param name="DisplayBackColor" value="0">
  <param name="DisplayForeColor" value="16777215">
  <param name="DisplayMode" value="0">
  <param name="DisplaySize" value="0">
  <param name="Enabled" value="-1">
  <param name="EnableContextMenu" value="-1">
  <param name="EnablePositionControls" value="-1">
  <param name="EnableFullScreenControls" value="0">
  <param name="EnableTracker" value="-1">
  <param name="Filename" value>
  <param name="InvokeURLs" value="-1">
  <param name="Language" value="-1">
  <param name="Mute" value="0">
  <param name="PlayCount" value="1">
  <param name="PreviewMode" value="0">
  <param name="Rate" value="1">
  <param name="SAMILang" value>
  <param name="SAMIStyle" value>
  <param name="SAMIFileName" value>
  <param name="SelectionStart" value="-1">
  <param name="SelectionEnd" value="-1">
  <param name="SendOpenStateChangeEvents" value="-1">
  <param name="SendWarningEvents" value="-1">
  <param name="SendErrorEvents" value="-1">
  <param name="SendKeyboardEvents" value="0">
  <param name="SendMouseClickEvents" value="0">
  <param name="SendMouseMoveEvents" value="0">
  <param name="SendPlayStateChangeEvents" value="-1">
  <param name="ShowCaptioning" value="0">
  <param name="ShowControls" value="-1">
  <param name="ShowAudioControls" value="-1">
  <param name="ShowDisplay" value="0">
  <param name="ShowGotoBar" value="0">
  <param name="ShowPositionControls" value="-1">
  <param name="ShowStatusBar" value="0">
  <param name="ShowTracker" value="-1">
  <param name="TransparentAtStart" value="0">
  <param name="VideoBorderWidth" value="0">
  <param name="VideoBorderColor" value="0">
  <param name="VideoBorder3D" value="0">
  <param name="Volume" value="-9640">
  <param name="WindowlessVideo" value="0">
</object>
</p>

</body>

</html>
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6250279
Questions?
0
 
LVL 2

Author Comment

by:kristofer
ID: 6251886
Thanks a lot Dave, just what I wanted. Sorry it took so long to reply, but I've been busy and I wanted to try the code...

Everything you've decribed works very well until I try to start html-file. A box comes up: "Some Software (ActiveX Controls) on this page may be unsafe. It is recommended that you not run it. Do you want to allow it to run?" I click yes and then I just see the grey control 400x400 pixels, no msg pops up like it did when I ran the ocx through an exe-project.

any ideas... thx

p.s. increased points to 50
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6253363
hey kristofer,

Post your html source here...  might be the culprit

-d
0
 
LVL 2

Author Comment

by:kristofer
ID: 6254568
Here it comes...
<HTML>
<HEAD>
<TITLE>Project1.CAB</TITLE>
</HEAD>
<BODY>
<!--     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">
     <PARAM NAME="LPKPath" VALUE="LPKfilename.LPK">
</OBJECT>
-->

<OBJECT ID="UserControl1" height="200" width="200"
CLASSID="CLSID:81B0339A-7123-11D5-8F3A-0050DAE6FCFC"
CODEBASE="Project1.CAB#version=1,0,0,0">
<param name="Message" value="Hello all">
</OBJECT>
</BODY>
</HTML>
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6255793
Ok, the html is correct, now it can only be one of two things.  Either the code in your UserControl isn't correct..(Not likely) or your browser settings need to be adjusted to accept unsigned controls.

Goto Tools>Internet Options>Security>Custom Level

Enable every option of ActiveX controls.  For deployment over the internet you would want sign your controls with verisign, but for testing purposes change the options above and try it again.

-d
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6278287
Any word on this one?
0
 
LVL 2

Author Comment

by:kristofer
ID: 6284787
Not yet, I 'm working on it and will get back to you.
0
 

Expert Comment

by:teacher_mod
ID: 6374596
Dave_Green,

Looks like they forgot to come back.  Please re-submit with an answer.  If that does not bring them back then I will accept it on their behalf.
TIA for helping to clean up the old questions.

teacher_mod
Community Support Moderator
Experts-Exchange
teacher_mod@experts-exchange.com


0
 
LVL 8

Accepted Solution

by:
Dave_Greene earned 50 total points
ID: 6374620
Hope this does it!
0
 
LVL 2

Author Comment

by:kristofer
ID: 6378809
sorry about the delay
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 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

19 Experts available now in Live!

Get 1:1 Help Now