A button can be created in an ActiveX control.
An ActiveX control is a software component that can be plugged into different programs and used as if it were a native part of the program. programmers can write ActiveX controls in any language that supports Component Object Model (COM) development. typical examples of ActiveX controls are command buttons, list boxes and dialog boxes. an ActiveX control can be created using Visual Basic, C # or VC ++. net.
-
Difficulty:
-
Challenging
Instructions Things you'll need:
- Visual Basic Editor
- C # Editor
- Visual c ++ Editor
- Visual Basic
- 1
Open MS Visual Basic and create a new project type as "ActiveX control ."
- 2
Create a command button, called extract test, and a text box, called txttest. Drag the controls from the toolbox to create these.
- 3
Add the following functions:
Public Function settext (txt as string)
Txttest. Text = txt
End Function
Private sub register test_click ()
Msgbox txttest. Text
End sub
This will pass a value to the text box from the web page. When a user clicks the command button, it will display this text in a message box.
- 4
Click on "Tools" and then "package and deployment wizard" to save the project. Save the project as an Internet package and name as "ctlvbactive ."
- 5
Create an HTML page in a text editor, such as Notepad.
- 6
Add the following code:
<Select id = "drpvalues" onclick = "send_value (this)">
<Option value = ""> </option>
<Option value = "value1"> value1 </option>
<Option value = "value2"> value2 </option>
<Option value = "value3"> value3 </option>
<Option value = "value4"> value4 </option>
<Option value = "value5"> value5 </option>
</SELECT>
<Object ID = "ctlvbactive"
Classid = "CLSID: 748fef73-28d1-4889-a582-e5f8f526cdd1"
Codebase = "vbactivex. Cab # version =,">
</Object>
- 7
Save and open the file in a browser.
C #
- 1
Open C # editor and create a new project.
- 2
Add the following code, to create an ActiveX control:
Using system;
Using system. runtime. interopservices;
Namespace anamespace
{
Public interface asignatures
{
String fname ();
String sname ();
Int age {Get ;}
}
[Classinterface (classinterfacetype. autodual)]
Public class Aclass: asignatures
{
Public String fname ()
{
Return "John ";
}
Public String sname ()
{
Return "Ryan ";
}
Public int age
{
Get {return 40 ;}
}
}
}
Save the file. Call it "Aclass. dll ."
- 3
Compile the file. the is done using a compiler file called "csc.exe," which is located at: \ windows \ Microsoft. net \ framework \ v2.0. open this compiler file, which opens as a console, and add the Code:
Regasm Aclass. dll/TLB/codebase
This class file created in the previous step is compiled and can be called from a HTML page.
- 4
Create an HTML file to call the ActiveX control:
<HTML>
<Head>
<Script language = "JavaScript">
<! -- Load the ActiveX Object -->
VaR x = new activexobject ("anamespace. Aclass ");
<! -- Access the method -->
Alert (X. fname ());
Alert (X. sname ());
<! -- Access the property -->
Alert (X. Age );
</SCRIPT>
</Head>
<Body>
</Body>
</Html>
- 5
Save the HTML file and run in a browser.
Visual c ++
- 1
Open the Visual C ++ editor.
- 2
Create a new project and select "ActiveX control ."
- 3
Add code to create a new icon
Void cmyactivexiconctrl: ondraw (CDC * PDC, const crect & rcbounds, const crect & rcinvalid)
Cbitmap: loadbitmap ()
CDC: stretchblt ()
This function will draw the ActiveX control icon.
- 4
Press F5 to run the program. in Visual C ++. net, the control is registered automatically.
- 5
Go to the "Tools" menu and click on ActiveX control test container. go to the "edit" menu and click on "insert control" option. A window will appear. check the "myactivex icon control," which now shows the ActiveX control test container you have created.
Read more: How to Write an ActiveX control | ehow.com http://www.ehow.com/how_7852194_write-activex-control.html#ixzz1KhwP99VS