Using an in-place activation control requires that you set a single property. The Src property is a string that stores the path and name, or the URL, of the file displayed by AutoCAD.
An in-place activation control also exports a single method that is called either explicitly or implicitly, depending on the host context. The PostCommand method sends a string from Display.exe to the command line of AutoCAD.
In the following two procedures, you use the control from the previous procedure in a Visual Basic application and in an HTML web page.
To use the in-place activation control in Microsoft Visual Basic
- Start Visual Studio.
- Open a new Visual Basic Windows Application project, and name it Display.exe.
- On the View menu, click Toolbox to show the Toolbox pane.
- In the Toolbox pane, right click to display the context menu, and click on Choose Items.
- In the Choose Toolbox Items dialog box, on the COM Components tab, select AutoCAD’s AcCtrl component AcCtrl.dll.
- Click Ok.
The AutoCAD in-place activation control is displayed in the Toolbox.
- Draw the control on Form(1), and then draw one command button.
- In the form’s
Load event handler, set the in-place activation control's Src property to a file path. For example, if a file named
colorwh.dwg
is in your computer's root directory, you can enter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Exception) Handles MyBase.Load AxAcCtrl1.Src = "C:\colorwh.dwg" End Sub
- In the command button's
Click event handler, call the control's PostCommand method, passing it a command string:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Exception) Handles Button1.Click AxAcCtrl1.Focus() AxAcCtrl1.PostCommand ("line") End Sub
Make sure that you pass a command string that is supported by your product.
You can include a space, if appropriate, as if you were using a command in AutoCAD. For example, enter Line 1,1 10,10, and include a space after the second 10. Or enter the command Zoom 10x, and include a space after 10x.
- Run the program.
The in-place activation control should display the file you specified in step 8
- Click the command button.
The command you passed in should affect the file in Display.exe's child window.
- Exit Display.exe.
To use the in-place activation control on a web page
- On a typical HTML page, within a pair of Paragraph tags (<P></P>), enter a pair of Object tags (<Object></Object>).
- Set the id attribute to Acad and the classid attribute to clsid:12490290-02E9-4B5E-BE0A-38E27EB98150.
- Specify width and height attributes in the Object tag. Set width to 400, and height to 300.
- Set PARAM NAME to Src and set VALUE to the URL of a file you want to view with AutoCAD. For example, enter the following text, replacing the URL values with values appropriate to your network:
<OBJECT id="Acad" classid="clsid:12490290-02E9-4B5E-BE0A-38E27EB98150" width=400 height=300> <PARAM NAME="src" VALUE="http://Your_Server_Name/Your_Path/colorwh.dwg"> </OBJECT>
- View the HTML page in Microsoft Internet Explorer. Please note that viewing the page in IE7 or later will prompt you with a script warning which will need to be responded to appropriately.
The in-place activation control should display the file whose URL you specified in the VALUE attribute in step 4.