INTERNAL: IDL ActiveX example using Micrsoft's C# .net
Topic:
Microsoft's new C# programming language can be used with IDL's activeX component. The following is a basic example of how to incorporate the IDL activeX component (IDLDrawWidget Control 3.0) into a Visual C# project.Discussion:
File->New Project
Name "idldrawx"
View->Toolbox
Right->click on the toolbox and select "Add Tab"
Type for example "IDL" as the name of the new tab
Click on the new tab
Right-click on the gray area on the new tab and select "Customize Toolbox..."
Click to add a check mark at "IDLDrawWidget Control 3.0"
Then hit OK
You should now see the IDLDrawWidget in the toolbox.
Add an IDLDrawWidget to the Form
Go to the Windows Forms tab and add a horizontal slider to the form
Double-click on the gray area in the form
An empty code stub should appear and add the following three lines of code:
private void Form1_Load(object sender, System.EventArgs e)
{
axIDLDrawWidget1.IdlPath="C:/rsi/idl60/bin/bin.x86/idl32.dll";
axIDLDrawWidget1.InitIDL((int) this.Handle);
axIDLDrawWidget1.CreateDrawWidget();
axIDLDrawWidget1.ExecuteStr("plot, sin(findgen(2)/3), xstyle=1, yrange=[-1,1]");
}
Go back to the form and double-click on the scrollbar
An empty code stub should appear and add the following lines of code:
private void hScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
axIDLDrawWidget1.ExecuteStr("a="+hScrollBar1.Value.ToString());
axIDLDrawWidget1.ExecuteStr("plot, sin(findgen(a>2)/3), xstyle=1, yrange=[-1,1]");
}
Run the program using F5.
You should now see a plot appear in the IDL draw widget.
The plot will automatically update as the slider is moved.Solution:
[Edit this field in the IDL-based Tech Tip Editor, v3]