OCX control Development and web JavaScript How to use OCX control __java

Source: Internet
Author: User

First, OCX control development

1, using the IDE version: VS2010

2. Develop OCX control based on MFC technology.

3. Basic OCX Development process

3.1, open vs 2010 New project, select MFC Template, "MFC ActiveX Control" "Visual C + + project", enter the name, all the way to the default.

3.2, the next face how to add OCX event and method to explain, select "Similar figure", as shown in the Figure red box:


Select the contents of a red box right click to add a method. The next dialog appears, prompting you to enter a method name.

Note: The first red box is the method action: is the outside can call the method.

The second red box is an event action: The OCX control sends information to the outside.

4.ocx Control Introduction dialog box

4.1 Add a resource for a dialog box to a resource view or select the Insert dialog item directly. Then right click on the dialog box to select the "Add Class" item and enter the name of the class you want.

4.2, then select the property, set the visible value to true, set the border value to None, set the style value to child, and set the system Modal value to True.

4.3, and then select Class View, right-click on the class name "Ctrl" to select the Add variable, which is the type of the class you just joined.

4.4, or in a similar diagram interface, select the same class, right-click the Open Class Wizard, select the message window, add wm_creat message events, as shown in the figure:


When you are done, add the following code to the function:

M_dlgtest.create (Idd_dialog1,this);
Change the variable m_dlgtest to the dialog class variable you just named.

4.5, modify the "Ctrl" file in the 4.4 OnDraw function, the original picture of the ellipse code deleted, plus the following code:

	Pdc->fillrect (Rcbounds, Cbrush::fromhandle (hbrush) getstockobject (White_brush));
	Pdc->ellipse (rcbounds);

	M_dlgtest.movewindow (Rcbounds, TRUE);
	CBrush Brbackgnd (TranslateColor (Ambientbackcolor ()));
	Pdc->fillrect (Rcbounds, &BRBACKGND);

The annotation above is to be deleted. Add the following code to the comment. As above, replace the variables with your class variables.

5, OCX in the introduction of OCX control.

5.1, in the resource you want to join OCX control Select the "Insert ActiveX Control" item, and then select the OCX control you want to join.

5.2, if not let this OCX display, please select the property to set the visible value to false. The default is true.

5.3, in the Resource OCX control right click Select Add variable, enter variable name.

5.4, then in the Solution resource management interface to select the "APP" word class file, in its InitInstance () function of the IF (binit) processing add the following code:

	if (binit)
	{
		//TODO: Add your own module initialization code here.
		AfxEnableControlContainer ();
		SetDialogBkColor (RGB (255,255,255));
	

Ii. Web JavaScript using OCX controls

1, first create an HTML file, the middle to <object></object> tag. As follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
</body>

Note the source of the ClassID in the:<object> label is OCX. You can find this classid in the source OCX project with an extension called ". idl", (usually the last one)

2, the JavaScript use OCX method.  var myocxtest = document.getElementById ("Myocx"); Myocxtest You can use the OCX control method.

3, JavaScript use OCX event, that is, OCX return information to the Web page. Method:

<script event= "OCX control event" for= "Myocx" >
    your code to process information
</script>

4, on the basis of the 3rd, that is, OCX return information to the interface, in this process also need to use the OCX method. If the above 3 code directly plus OCX event, will be browser card dead, not normal use. However, if the OCX event with a timer delay after a period of time can be normal. Reason: May be because OCX will return the information after not too late to destroy, the Web page began to use OCX method. So the Web page thread jam causes the card death phenomenon. "This is what I see after the phenomenon summed up, not necessarily the truth, if you have Bo friends know its principles please tell, share your technology, service thousands of front-end developers."

<script event= "OCX control event" for= "Myocx" > <pre name= "  Code" class= "JavaScript" ><span style= " White-space:pre ">	</span>settimeout (function () {
<span style= "White-space:pre" >		</span>myocx.getname ();
	},1500);
</script>









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.