以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- VB,C#代码用在fox (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=129202) |
-- 作者:超古伯 -- 发布时间:2018/12/24 9:04:00 -- VB,C#代码用在fox 请教老师,下面一段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); } } } } |
-- 作者:有点甜 -- 发布时间:2018/12/24 9:15:00 -- 全局代码
Public Sub CreateTextInCorelDRAW(text As String, fontName As String, fontSize As Single) Dim pia_type As Type = Type.GetTypeFromProgID("CorelDRAW.Application.17") Dim app As object = Activator.CreateInstance(pia_type) app.Visible = True Dim doc As object = app.ActiveDocument If doc Is Nothing Then doc = app.CreateDocument() Dim shape As object = doc.ActiveLayer.CreateArtisticText( _ End Sub
|