请教老师,下面一段vb代码用在fox该怎么做?先引用Corel.Interop.VGCore.dll?然后代码该怎么改呢,代码放在哪里呢?
Imports Corel.Interop.VGCore
Module Module1
Sub CreateTextInCorelDRAW(text As String, fontName As String, fontSize As Single)
Dim pia_type As Type = Type.GetTypeFromProgID("CorelDRAW.Application.17")
Dim app As Application = Activator.CreateInstance(pia_type)
app.Visible = True
Dim doc As Document = app.ActiveDocument
If doc Is Nothing Then doc = app.CreateDocument()
Dim shape As Shape = doc.ActiveLayer.CreateArtisticText(
0.0, 0.0, text, cdrTextLanguage.cdrLanguageMixed,
cdrTextCharSet.cdrCharSetMixed, fontName, fontSize,
cdrTriState.cdrUndefined, cdrTriState.cdrUndefined,
cdrFontLine.cdrMixedFontLine, cdrAlignment.cdrLeftAlignment)
End Sub
Sub Main()
Try
CreateTextInCorelDRAW("Hello, world", "Arial", 24.0F)
Catch ex As Exception
Console.WriteLine("Error occurred: {0}", ex.Message)
End Try
End Sub
End Module
下面是一段同样效果的C#代码,也是不清楚该怎么用在fox
using System.Text;
using System.Threading.Tasks;
using Corel.Interop.VGCore;
namespace TextCreatorCS
{
class Program
{
static void CreateTextInCorelDRAW(string text, string fontName,
float fontSize)
{
Type pia_type = Type.GetTypeFromProgID("CorelDRAW.Application.17");
Application app = Activator.CreateInstance(pia_type) as Application;
app.Visible = true;
Document doc = app.ActiveDocument;
if (doc == null)
doc = app.CreateDocument();
Shape shape = doc.ActiveLayer.CreateArtisticText(
0.0, 0.0, text, cdrTextLanguage.cdrLanguageMixed,
cdrTextCharSet.cdrCharSetMixed, fontName, fontSize,
cdrTriState.cdrUndefined, cdrTriState.cdrUndefined,
cdrFontLine.cdrMixedFontLine, cdrAlignment.cdrLeftAlignment);
}
static void Main(string[] args)
{
try
{
CreateTextInCorelDRAW("Hello, world", "Arial", 24.0f);
}
catch (Exception ex)
{
Console.WriteLine("Error occurred: {0}", ex.Message);
}
}
}
}