Add properties and events when writing your own client Side ocx in VB

Source: Internet
Author: User
In fact, the use is not very large, because such OCX to run, must have digital signature, but also need to agree to install, or you will be prompted every time, what is not safe and so on.
Create an ActiveX control in VB and select the ActiveX Control Interface Wizard in the Add-in menu (if not, add one to the Add-in manager)
You can define the method you want here, the property, the event, and if you want to invoke the client Script, map to the members of the control at the step of setting up the mapping.
When it's done, it will give you this code (I added a MouseMove event)
Event MouseMove (Button As Integer, Shift As Integer, X as single, Y as single) ' Mappinginfo=usercontrol,usercontrol,-1,mou Semove
Private Sub usercontrol_mousemove (Button As Integer, Shift As Integer, X as single, Y as single)
RaiseEvent MouseMove (Button, Shift, X, Y)
End Sub
This will allow the client script to respond to this event.
<script language=vbscript>
Sub Obj1_mousemove (Button, Shift, X, Y)
If Button = 4 Then MsgBox (X & "," & Y)
End Sub
</SCRIPT>
In JavaScript I still do not know how to get button,shift, x,y these parameters, but ActiveX can only be used in IE, so it doesn't matter.
Adding a property to the code would be a lot of trouble, but I'm glad I didn't write
Attention Do not delete or modify the following commented lines!
' Mappinginfo=usercontrol,usercontrol,-1,backcolor
Public Property Get BackColor () as Ole_color
BackColor = Usercontrol.backcolor
End Property
Public Property Let BackColor (ByVal New_backcolor as OLE_COLOR)
Usercontrol.backcolor () = New_backcolor
PropertyChanged "BackColor"
End Property
' Load the property value from the memory
Private Sub usercontrol_readproperties (propbag as PropertyBag)
Usercontrol.backcolor = Propbag.readproperty ("BackColor", &h8000000f)
End Sub
' Write attribute values to storage
Private Sub usercontrol_writeproperties (propbag as PropertyBag)
Call Propbag.writeproperty ("BackColor", Usercontrol.backcolor, &h8000000f)
End Sub
The rest is the same as writing an ordinary ActiveX component.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.