objects

If i add an ocx control to a webpage...an activex control, how can i execute a method from that control?
wormboy__6Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DreamMasterCommented:
You'll have to be more specific than that wormboy...

Max Davidse
http://www.thekitchen.nl
0
wormboy__6Author Commented:
ok.

you know how you can add an activex control to a web page.

Well in visual basic...with these controls..they each have properties, events and methods.

eg. the winsock control has a method Listen.
In visual basic i call the listen command by typing:

Winsock1.Listen

On a web page, how do i addd a control execute a method like this.
You can use the winsock control as an example.
It is mswinsock.ocx
0
DreamMasterCommented:
well..

i don't know about the mswinsock.ocx but i have used an activex control for controlling a flash file...

easy might be a little underqualified for this question, but i will try to explain it with the following code...

<HTML>
<HEAD>
<TITLE>VODW Jumpstation</TITLE>
<script language="VBScript">
<!--
sub IEdetected
      on error resume next
        dim Flashmode
      
      Flashmode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))
      if not Flashmode Then
            FlashMode = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))
      End If
               
      if not Flashmode then
            document.writeln " <frameset rows=""*,445,*""> "
            document.writeln "       <frame name=""witboven"" src=""http://www.vodw.com/vodw/smartsite.asp?id=130"" framespacing=""0"" frameborder=""no"" border=""0"" scrolling=""no"" resize> "
            document.writeln "      <frameset cols=""*,795,*""> "
            document.writeln "            <frame name=""witlinks"" src=""http://www.vodw.com/vodw/smartsite.asp?id=130"" framespacing=""0"" frameborder=""no"" border=""0"" scrolling=""no"" resize> "
            document.writeln "            <frame name=""vodw jumpstation"" src=""http://www.vodw.com/vodw/smartsite.asp?id=817"" framespacing=""0"" frameborder=""no"" border=""0"" scrolling=""no"" noresize> "
            document.writeln"            <frame name=""witrechts"" src=""http://www.vodw.com/vodw/smartsite.asp?id=130"" framespacing=""0"" frameborder=""no"" border=""0"" scrolling=""no"" resize> "
            document.writeln "      </frameset> "
            document.writeln "  <frame name=""witonder"" src=""http://www.vodw.com/vodw/smartsite.asp?id=130"" framespacing=""0"" frameborder=""no"" border=""0"" scrolling=""no"" resize> "
            document.writeln " </frameset> "
      end if
end sub  

sub IEv3
end sub

Sub banner_FSCommand(ByVal command, ByVal args)
    call banner_DoFSCommand(command, args)
end sub
//-->
</script>

<script language="Javascript">
<!--
      function MM_checkPlugin(plugin, theURL, altURL, IEGoesToURL) { //v2.0
        if ((navigator.plugins && navigator.plugins[plugin]) || //if NS, or
            (IEGoesToURL &&  //if flag set, and MSIE browser for Win95/NT (ActiveX)
             navigator.appName.indexOf('Microsoft') != -1 &&
             navigator.appVersion.indexOf('Mac') == -1 &&
             navigator.appVersion.indexOf('3.1') == -1)) {
          if (theURL.length>2) window.location = theURL;
        } else {
          if (altURL.length>2) window.location = altURL;
        }
        document.MM_returnValue = false;
      }
    //-->
      </script>
<SCRIPT LANGUAGE=JavaScript>
<!--
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the the FSCommand messages in a FutureSplash movie

function banner_DoFSCommand(command, args) {
  var bannerObj = InternetExplorer ? banner : document.banner;
  if (command == "executives")
  {
   parent.location.replace('http://www.vodw.com/executives');
  }
  if (command == "strategy")
  {
   parent.location.replace('http://www.vodw.com/strategy');
  }
  if (command == "werkenbij")
  {
    parent.location.replace('http://www.vodw.com/vodw/smartsite.asp?id=23');
  }
  if (command == "mrim")
  {
   parent.location.replace('http://www.vodw.com/recrutering');
  }
  if (command == "makingwaves")
  {
   parent.location.replace('http://www.vodw.com/makingwaves');
  }
}

//-->
</SCRIPT>

</head>


<script language="Javascript">
<!--
  var AppName = navigator.appName;
  var IsExplorer = AppName.indexOf("Microsoft")!=-1;
  var IsNetscape = AppName.indexOf("Netscape")!=-1;
  var IsMac = navigator.platform && (navigator.platform.indexOf('Mac')!=-1);
  var versie = parseInt(navigator.appVersion);

  if (IsMac && IsExplorer) location.href='smartsite.asp?id=813';
  if (IsNetscape)
    MM_checkPlugin('Shockwave Flash','','http://www.vodw.com/vodw/smartsite.asp?id=844',true)
  else if (IsExplorer)
  {
     if (versie >= 4)
       IEdetected();
     else
       location.href='smartsite.asp?id=844';
  }
//-->
</script>

<BODY bgcolor="#000033">


<SCRIPT LANGUAGE="JavaScript" SRC="http://www.macromedia.com/shockwave/download/smart/getsw.js">
function getShockwave()
{
window.open( "http://www.macromedia.com/shockwave/download/", "" );
}
</script>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0"
 ID=banner WIDTH="100%" HEIGHT="100%">
  <PARAM NAME=movie VALUE="pics/intro.swf">
  <PARAM NAME=quality VALUE=high>
  <PARAM NAME=menu VALUE=false>
  <PARAM NAME=bgcolor VALUE=#000033>
<SCRIPT LANGUAGE=JavaScript>
<!--
var ShockMode = 0;
var OldVersionOfPlugin = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
      if (navigator.plugins && navigator.plugins["Shockwave Flash"])
            ShockMode = 1;
      else
            OldVersionOfPlugin = 1;
}
function checkForShockwave()
{
      navigator.plugins.refresh();
      if ( navigator.plugins["Shockwave Flash"] ){
            parent.location.reload();
      } else {
            setTimeout( "checkForShockwave()", 1000 );
      }
}
if (!ShockMode && navigator.appName && navigator.appName.indexOf("Netscape") != - 1 && navigator.appVersion.indexOf("4.") != - 1
&& navigator.javaEnabled() && netscape.softupdate.Trigger.UpdateEnabled() && document.cookie.indexOf("StartedShockwaveInstall") == -1) {
      var jarPath = new String("");
      if (navigator.platform.indexOf("Win32") >= 0 )
            jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash32.jar"
      else if (navigator.platform.indexOf("Win16") >= 0 )
            jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash16.jar"
      else if (navigator.platform.indexOf("MacPPC") >= 0 )
            jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflashppc.jar"
      if (jarPath.length) {
            netscape.softupdate.Trigger.StartSoftwareUpdate (jarPath, netscape.softupdate.Trigger.FORCE_MODE);
            document.cookie='StartedShockwaveInstall;path=/;'
            setTimeout("checkForShockwave()", 1000);
      }
}
if ( ShockMode ) {
      document.write('<EMBED SRC="pics/intro.swf" WIDTH=100% HEIGHT=100%');
      document.write(' NAME=banner swLiveConnect=TRUE ');
      document.write(' QUALITY=high SCALE=noborder MENU=false BGCOLOR=#000033');
      document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
      document.write('</EMBED>');




now i know this is a lot of code and i also gave You a big browser detection script that even works on Mac browsers along with this...

This code You see here is from the VODW site i made...it uses FS-Commands, and because IE and NS do it differently,
IE uses an ActiveX control to control the Flash movie...

see if this helps You with Your question..

Max Davidse
http://www.thekitchen.nl
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

wormboy__6Author Commented:
hmmmm i didnt know that this was a hard question..but ill raise the points to 200.

Ummmm i cant work out what to do from your code...
Could you..or someone else..write a short piece of code that will add a control (say the mswinsck.ocx) and make it listen.

I can see that you have done what i want...but i dont know how to do it myself..could you edit your code DreamMaster so that i could understand...

Thanks
0
DreamMasterCommented:
ok...i'll try..

<html>
<head>
  <title>Test</title>
<script language="VBScript">
<!--
// the following function is what You need in this case to make IE understand what it is supposted to do.
Sub banner_FSCommand(ByVal command, ByVal args)
    call banner_DoFSCommand(command, args)
end sub
//-->
</script>

<script language="javascript">
<!--
// now to make it listen
function banner_DoFSCommand(command, args)
{
  var bannerObj = InternetExplorer ? banner : document.banner;
  if (command == "command1")
  {
      do something
  }
}
//-->
</script>

You can also use arguments (args), now i know this is a Flash specific sollution but i hope You will be able to make the necessary changes to make it support Your ocx file..

This should work the same because Flash is displayed in IE using active-X controls.

good luck.

Hope this is better....
0
wormboy__6Author Commented:
ok...i have a mental block..i can't think

Could you use the winsock control as an example in this short piece of code...

thanks
0
DreamMasterCommented:
geez,

never used that before...

i'll have to look that up too..

and anyway...You're welcome...
0
DreamMasterCommented:
ok....i've looked through some books and i have the following information for You...

Just make Your active-x control, like You're used to, don't forget to give it a name though...

now when You want to make sure Your active-x control does in fact support commands to be received, and which ones the are...use:

objectname.Verbs

this doesn't always work, in fact it's buggy...but it's the only way to find out what commands can be given to Your control.

Max Davidse
http://www.thekitchen.nl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wormboy__6Author Commented:
Do i do this in vbscript or what?

Could you do a little example that i can paste stright into a page..
0
DreamMasterCommented:
yes in VBScript, active-x is VB..

do something like:

document.write "winsock1.Verbs"

or whatever other function You use to write output to the screen.

i thought this has to be very clear..
what more can i possibly tell You? just try it and it should generate a list of commands available...if there are none...then there simply are no commands..sorry, can't help any better then that..
0
wormboy__6Author Commented:
Ok, i put this exact code into a web page:

<html>

<head>
<title>Test Button Events</title>
</head>

<body>

<form NAME="Form1">
  <p>
  <object id="Winsock" classid="clsid:248DD896-BB45-11CF-9ABC-0080C7E7B78D" width="28"
  height="28">
  </object>
  &nbsp;<input TYPE="Button" NAME="Button1" VALUE="Click"> <script FOR="Button1"
  EVENT="onClick" LANGUAGE="VBScript"> MsgBox Winsock.State


 </script> </p>
</form>
</body>
</html>

But i get an error in the script and it says "Object required 'Winsock'."
But i have added a winsock control with a name winsock..havent i?
What am i doing wrong?
0
wormboy__6Author Commented:
Here is an example from a piece of documentation..i thik this does what i want...but i cant do it.

Could you have a look at it and help me please as to what to do.

Whether you use an ActiveX® control (formerly called an OLE control) or a Java™ object, Microsoft Visual Basic Scripting Edition and Microsoft® Internet Explorer handle it the same way. If you're using Internet Explorer and have installed the Label control, you can see the page produced by the following code.
You include an object using the <OBJECT> tags and set its initial property values using <PARAM> tags. If you're a Visual Basic programmer, you'll recognize that using the <PARAM> tags is just like setting initial properties for a control on a form. For example, the following set of <OBJECT> and <PARAM> tags adds the ActiveX Label control to a page:

<OBJECT
      classid="clsid:99B42120-6EC7-11CF-A6C7-00AA00A47DD2"
      id=lblActiveLbl
      width=250
      height=250
      align=left
      hspace=20
      vspace=0
>
<PARAM NAME="Angle" VALUE="90">
<PARAM NAME="Alignment" VALUE="4">
<PARAM NAME="BackStyle" VALUE="0">
<PARAM NAME="Caption" VALUE="A Simple Desultory Label">
<PARAM NAME="FontName" VALUE="Verdana, Arial, Helvetica">
<PARAM NAME="FontSize" VALUE="20">
<PARAM NAME="FontBold" VALUE="1">
<PARAM NAME="FrColor" VALUE="0">
</OBJECT>

You can get properties, set properties, and invoke methods just as with any of the form controls. The following code, for example, includes <FORM> controls you can use to manipulate two properties of the Label control:
<FORM NAME="LabelControls">
<INPUT TYPE="TEXT" NAME="txtNewText" SIZE=25>
<INPUT TYPE="BUTTON" NAME="cmdChangeIt" VALUE="Change Text">
<INPUT TYPE="BUTTON" NAME="cmdRotate" VALUE="Rotate Label">
</FORM>

With the form defined, an event procedure for the cmdChangeIt button changes the label text:
<SCRIPT LANGUAGE="VBScript">
<!--
Sub cmdChangeIt_onClick
      Dim TheForm
      Set TheForm = Document.LabelControls
      lblActiveLbl.Caption = TheForm.txtNewText.Value
End Sub
-->
</SCRIPT>

How can i use this except for a winsock control and invoking the method listen (or any control for that matter)
0
wormboy__6Author Commented:
Ok...i have worked it all out.


It was so simple.. all i had to do was add an object and then do this code:

<script LANGUAGE="VBScript">
<!--
   msgbox object.state
-->
</script>

One more question though...can i call the windows API from a webpage via scripting on the client.

I mean, can i call the person with the browser's API?
0
DreamMasterCommented:
You should be able to but that's a totally different question...

was my answer helpfull to You?

i think You should post the question about the windows API as a new question and close this question by either accepting my answer or deleting the question as You have the answer now..either with my help or not..(well i did help...that's for sure)

Max Davidse
http://www.thekitchen.nl
email: max@thekitchen.nl
0
wormboy__6Author Commented:
yep i was going to give it to you...i just wanted to know whether it was possible
0
DreamMasterCommented:
ok man...

good luck on getting the Windows API working, if You ever need help on other subjects...don't hesitate to contact me...either on these pages or by email directly...

my email adres at my work is.

max@thekitchen.nl

and the one i use at home is

david315@wxs.nl

see ya around man..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.