Code Comments
Programming Forum and web based access to our favorite programming groups.I have created a ActiveX control in VB6 where I raise an event:
...
Public Event FilesDropped()
...
RaiseEvent FilesDropped
...
Then, in a web page, I include my control using the OBJECT-tag, and
then try to listen for this event:
<OBJECT ID="DropArea"
CLASSID="CLSID:0B895E9F-B0CD-450F-9268-BA4AD07EEDFF"
CODEBASE="IFSDropArea.CAB#version=1,0,0,0">
<PARAM NAME="AREAWIDTH" VALUE="333">
<PARAM NAME="AREAHEIGHT" VALUE="55">
</OBJECT>
<script for="DropArea" event="FilesDropped">
alert("Hello!");
</script>
When the event is triggered by the control, nothing happens.
I am able to catch events from other, ready-made controls. This code
works, for example:
<OBJECT CLASSID="clsid:79176FB0-B7F2-11CE-97EF-00AA006D2776"
ID="spnTest"
CODEBASE="http://activex.microsoft.com/controls/mspert10.cab">
</OBJECT>
<SCRIPT for="spnTest" event="Change">
alert("Hello!");
</SCRIPT>
I am starting to suspect that there is something wrong with the event
that VB creates. Can anyone help?
Post Follow-up to this message"Barman Brakjoller" <brakjoller@gmail.com> wrote in message news:1129138687.472995.222720@o13g2000cwo.googlegroups.com... >I have created a ActiveX control in VB6 where I raise an event: > > When the event is triggered by the control, nothing happens. What's supposed to happen? What are you using to trap the events? To get events from an object, you have to reference a specific instance of that object. (you probably already know that) Since I've never done anything "real" in IE, I don't have a clue. What I do know is.... VB authored ActiveX components are as good as any you'll find anywhere. They do have a few "gotchya"'s as far as resources and the way they're instantiated but their events work fine. Maybe the article below will help..... How To Enable ActiveX Control Event Handling on a Web Page http://support.microsoft.com/defaul...kb;en-us;200839 -- Ken Halter - MS-MVP-VB - http://www.vbsight.com DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Please keep all discussions in the groups..
Post Follow-up to this messageHi Ken, thanks for taking interest in this problem. This morning, when I woke up I got an idea: what if the reason that the event does not propagate is because of me running in Visual Basic debug mode? I just arrived to work, compiled the ocx properly and ran the web page without VB in debug mode... And it worked! I recreated the problem by starting the code in debug mode again (where I can step through the code etc). Then it does not work. So, for the record, if anyone else getting "strange" problems when doing VB development, make sure you don't rely totally on the debug mode in VB. Always test with the pure compiled ocx/dll/whatever. Yes, it was sloppy of me not to test this yesterday, but using debug mode when adding item after item when developing is very handy. Just press "play" and test.
Post Follow-up to this messageOne more thing that I wanted to get down in writing:
Instead of using this syntax to catch the event:
<script for="DropArea" event="FilesDropped">
alert("Hello!");
</script>
you can use this:
<script>
function DropArea::FilesDropped()
{
alert("Hello!");
}
</script>
Both works.
"function DropArea.FilesDropped()" and "function
DropArea_FilesDropped()" does not work in javascript, but "Sub
DropArea_FilesDropped()" works for vbscript:
<script language="vbscript">
Sub DropArea_FilesDropped()
MsgBox "Hello!"
End sub
</script>
Now this should have been sorted out for ever! :)
Post Follow-up to this messagequote:Thanks for the post, it got me in the correct direction definately. The only part that is still causing issue, is the "alternate" syntax you lis t. Here is my sample. ( NOTE ! You need to change all $'s to left brackets (less than signs) and change all @'s to right brackets (greater than sign), because this forum wou ldn't let me post with actual left or right brackets. //End Note ) $html@ $head@ $script language="JavaScript"@ var hasbeenSelectedBGR=false; var hasbeenSelectedBGG=false; var hasbeenSelectedBGB=false; $/SCRIPT@ $script language="JavaScript"@ function CheckForAllThree() { //alert("Entered the CheckForAllThree function"); if ( hasbeenSelectedBGR==true && hasbeenSelectedBGG==true && hasbeenSelecte dBGB==true ) { alert("All three have been changed"); } else { alert("You still need to alter the value of another control\n\r" + hasbeen SelectedBGR + "\n\r" + hasbeenSelectedBGG + "\n\r" + hasbeenSelectedBGB); } } $/SCRIPT@ $script language="JavaScript"@ function SetFocusOffOfActiveX() { frmTest.txtValue.focus(); } $/script@ $script language="JavaScript" for="scrollBGR" event="Change"@ //alert(scrollBGR.value); frmTest.txtValue.value=scrollBGR.value; hasbeenSelectedBGR=true; SetFocusOffOfActiveX(); $/SCRIPT@ $script language="JavaScript" for="scrollBGG" event="Change"@ //alert(scrollBGG.value); frmTest.txtValue.value=scrollBGG.value; hasbeenSelectedBGG=true; SetFocusOffOfActiveX(); $/SCRIPT@ $script language="JavaScript" for="scrollBGB" event="Change"@ //alert(scrollBGB.value); frmTest.txtValue.value=scrollBGB.value; hasbeenSelectedBGB=true; SetFocusOffOfActiveX(); $/SCRIPT@ $script@ function scrollBGB::Change() { alert("scrollBGB::Change"); } $/script@ $/head@ $body@ $form name="frmTest"@ $TABLE ID="myTable" BORDER="1" WIDTH="100" HEIGHT="100"@ $TR bgcolor='yellow'@ $TD ALIGN="CENTER"@ $OBJECT ID="scrollBGR" CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D" CODEBASE="http://activex.microsoft.com/controls/mspert10.cab"@ $PARAM NAME="Max" VALUE="255"@ $PARAM NAME="LargeChange" VALUE="5"@ $/OBJECT@ $OBJECT ID="scrollBGG" CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D" CODEBASE="http://activex.microsoft.com/controls/mspert10.cab"@ $PARAM NAME="Max" VALUE="255"@ $PARAM NAME="LargeChange" VALUE="5"@ $/OBJECT@ $OBJECT ID="scrollBGB" CLASSID="CLSID:DFD181E0-5E2F-11CE-A449-00AA004A803D" CODEBASE="http://activex.microsoft.com/controls/mspert10.cab"@ $PARAM NAME="Max" VALUE="255"@ $PARAM NAME="LargeChange" VALUE="5"@ $/OBJECT@ $/TD@ $/TR@ $tr@ $td@ $input type="text" name="txtValue"@ $/td@ $/tr@ $tr@ $td@ $INPUT TYPE="button" VALUE="Check for all 3 activex controls being changed" onClick="CheckForAllThree();"@ $br/@ $a href="#" onClick="CheckForAllThree();"@Check$/a@ $/td@ $/tr@ $/TABLE@ $/form@ $/body@ $/html@ Notice the scrollBGB::Change code, where I try to mimick what you did. If I leave the block in: $script@ function scrollBGB::Change() { alert("scrollBGB::Change"); } $/script@ When the page loads, there is an error, because it doesn't know what scrollB GB is. The other issue, is the .focus work around I put in. If I leave this out, you have to click the button (on the output page) twice , one to get the focus away from the activex control, and then one to trigge r the onClick event. Let me know what I'm doing wrong with the alternate syntax (the object::meth od syntax). Thanks. ....
Originally posted by Barman Brakjoller One more thing that I wanted to get down in writing: Instead of using this syntax to catch the event: $script for="DropArea" event="FilesDropped"@ alert("Hello!"); $/script@ you can use this: $script@ function DropArea::FilesDropped() { alert("Hello!"); } $/script@ Both works. "function DropArea.FilesDropped()" and "function DropArea_FilesDropped()" does not work in javascript, but "Sub DropArea_FilesDropped()" works for vbscript : $script language="vbscript"@ Sub DropArea_FilesDropped() MsgBox "Hello!" End sub $/script@ Now this should have been sorted out for ever! :)
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.