- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am building a custom Task, and I would like to add a SAS editor control for code preview in my task. What control should I use? I don’t want to use the .NET TextBox.
(When I add SAS.EG.Controls.dll to my .NET project reference and to the ToolBox, many SAS-supplied controls such as SASDatasetSelector appear, but there is no SAS editor control).
Thanks for any help,
Maurice
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In the examples on our web site at http://support.sas.com/eguide, there are a few tasks that show this. For example, the "SAS Catalog Explorer" and the "Simple SAS Program Editor" use the enhanced editor.
The key assemblies are SAS.AxInterop.EDITORCONTROLLib.dll and SAS.Interop.EDITORCONTROLLib.dll.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I downloaded the examples, AxInterop.EDITORCONTROLLib.dll and Interop.EDITORCONTROLLib.dll must be referenced.
But unlike the controls in the SAS.EG.Controls.dll, it seems not possible to add the editor control on the toolbox so that it can be drag and dropped on the form (Error message: “There are no components in ‘C:\Program Files\SAS\Enterprise Guide 4\SAS.AxInterop.EDITORCONTROLLib.dll’ that can be placed on the toolbox.”)....
Thanks,
Maurice
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't recommend using the designer to deal with the enhanced editor control. Instead, I would use a placeholder control (like a panel) and then dynamically create the editor control when your form is loaded.
For example, declare this:
[pre]
private AxEDITORCONTROLLib.AxEditorControl ctlEditor = null;
[/pre]
Then in OnLoad(), do this:
[pre]
ctlEditor = new AxEDITORCONTROLLib.AxEditorControl();
ctlEditor.Location = panelPlaceholder.Location;
ctlEditor.Visible = true;
ctlEditor.Dock = panelPlaceholder.Dock;
// add handler for when the control is finished being created
ctlEditor.HandleCreated += new EventHandler(ctlEditor_HandleCreated);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.ctlEditor});
[/pre]
Then be sure not to reference the control's methods until the handle is created. This is not uncommon when dealing with ActiveX controls via COM interop. It might take a moment to initialize, and you cannot call into it before it's ready.
[pre]
// control is created - now open file
private void ctlEditor_HandleCreated(object sender, EventArgs e)
{
if (file.Length>0)
ctlEditor.OpenFile(file);
ctlEditor.SetLanguage(4); // set language to SAS for syntax coloring
}
[/pre]
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How to enable SAS-Log syntax-highlighting such as red error-messages? Can I use the SetLanguage method? But which integer value to set?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The control you want is in SAS.Tasks.Toolkit.dll, and the control is:
SAS.Tasks.Toolkit.Controls.SASTextEditorCtl
It has a property that you can set:
ContentType = SAS.Tasks.Toolkit.Controls.SASTextEditorCtl.eContentType.SASProgram;
or
ContentType =
SAS.Tasks.Toolkit.Controls.SASTextEditorCtl.eContentType.SASLog
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
unfortunately we are using EG 4.1. Is there another way using this version?
Thanks, Florian
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Scott Barry
SBBWorks, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
6
Recommend that you set the properties in this order (assuming you like your log view to be read-only):
editor.ReadOnly=true;
editor.SetLanguage(6);
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Chris
Note I use VB 2008, Guide 4.3
I followed your instructions to insert an editor in a Cutom Task. But on a machine equiped by only Enterprise Guide, i got this error:
System.Runtime.InteropServices.COMException
Classe non enregistrée (Exception de HRESULT : 0x80040154 (REGDB_E_CLASSNOTREG))
------------------------------ Début des informations techniques------------------------------
System.Runtime.InteropServices.COMException (0x80040154): Classe non enregistrée (Exception de HRESULT : 0x80040154 (REGDB_E_CLASSNOTREG))
à System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
à System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
à System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
à System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
à System.Windows.Forms.AxHost.CreateInstance()
à System.Windows.Forms.AxHost.GetOcxCreate()
à System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
à System.Windows.Forms.AxHost.CreateHandle()
à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
à System.Windows.Forms.Control.CreateControl()
à System.Windows.Forms.Control.SetVisibleCore(Boolean value)
à System.Windows.Forms.TabPage.set_Visible(Boolean value)
à System.Windows.Forms.TabControl.UpdateTabSelection(Boolean updateFocus)
à System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
à System.Windows.Forms.TabControl.WmSelChange()
à System.Windows.Forms.TabControl.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Victor,
In EG 4.3 the process is different, but even easier. You can simply use the SAS.Tasks.Toolkit.Controls.SASTextEditorCtl class.
There are examples here:
http://go.sas.com/customtasksapi
See the SAS Program Runner project, for example.
Also, this is described in my book: Custom Tasks for SAS Enterprise Guide using Microsoft .NET
The book features an example in Chapter 12, and the source code for that project is available here (and described in this blog post😞
Custom Tasks for SAS Enterprise Guide using Microsoft .NET (Examples)
And finally, you can also see the same source code on GitHub:
cjdinger/SasDatasetToDataStep · GitHub
Specifically:
SasDatasetToDataStep/src/DS2DatalinesForm.cs at master · cjdinger/SasDatasetToDataStep · GitHub
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is what i finally did. It's so simple.
I should look your book more often.
Thank's any way