The example to add menus in Visual Basic by code in the documentation needs a little massaging to get it working. My code below works for me in VS 2005.
It requires a MainMenu which is no longer used much in Visual Studio 2005 (replaced by MenuStrip but still available for backwards compatability).
If anyone can get it to work with a MenuStrip that would be great as it is a much better looking control which you can add images to :)
Note modification to Enum and
should be
Also
should be
Code
Public Function CurrEdit() As WPDLLInt Implements WPDynamic.IGetCurrEditor.CurrEdit Return Me.WpdllInt1 End Function
I am still amazed at what TextDynamic can do and I have only touched the surface.
GRS
Code
Imports WPDynamic
Public Class Form1
Implements IGetCurrEditor
Enum wpaMenuCaps
wpaDropDownMenuFile = 1
wpaDropDownMenuEdit = 2
wpaDropDownMenuView = 4
wpaDropDownMenuInsert = 8
wpaDropDownMenuFormat = 16
wpaDropDownMenuExtras = 32
wpaDropDownMenuData = 64
wpaDropDownMenuTable = 128
wpaDropDownMenuWindow = 256
wpaDropDownMenuInfo = 512
End Enum
Private Sub UpdateMenu(ByVal menu As MainMenu, ByVal selection As wpaMenuCaps)
Dim textArrayArray1 As String()() = New String(10 - 1)() {}
' FILE
textArrayArray1(0) = New String() {"DiaOpen", "DiaSave", "-", "DiaPagePropEx", "DiaPreview", "DiaPrint"}
' EDIT
textArrayArray1(1) = New String() {"undo", "redo", "-", "DiaFind", "DiaReplace", "-", "copy", "paste", "SelAll"}
' VIEW
textArrayArray1(2) = New String() {"DiaManageHeaderFooter", "ShowCR", "-", "LayoutNormal", "zoom100", "zoomwidth", "zoomfullpage", "zoomdoublepage"}
' INSERT
textArrayArray1(3) = New String() {"DiaINSGRAPHIC", "DiaINSSymbol", "DiaINSHyperlink", "DiaINSFields"}
' FORMAT
textArrayArray1(4) = New String() {"DiaParagraphProp", "DiaParagraphBorder", "DiaBulletOutlines"}
' EXTRAS
textArrayArray1(5) = New String() {"DiaSpellcheck", "DiaSpellOptions", "SpellAsYouGo"}
' DATA - reserved
Dim textArray8 As String() = New String(0 - 1) {}
textArrayArray1(6) = textArray8
' TABLE
textArrayArray1(7) = New String() {"DiaINSTable", "DiaParagraphBorder", "InsColBefore", "InsCol", "InsRowBefore", "InsRow"}
' WINDOW
Dim textArray10 As String() = New String(0 - 1) {}
textArrayArray1(8) = textArray10
' INFO
textArrayArray1(9) = New String() {"DiaWPAbout", "DiaWPDebug"}
Dim textArray1 As String() = New String() {"DropDownMenuFile", "DropDownMenuEdit", "DropDownMenuView", "DropDownMenuInsert", "DropDownMenuFormat", "DropDownMenuExtras", "DropDownMenuData", "DropDownMenuTable", "DropDownMenuWindow", "DropDownMenuInfo"}
Dim num1 As Integer = 0
Dim num2 As Integer = 1
Do While (num1 <= 10)
If ((selection And CType(num2, wpaMenuCaps)) = CType(num2, wpaMenuCaps)) Then
Dim item2 As New WPAMenuItem(Me, textArray1(num1))
Dim textArray13 As String() = textArrayArray1(num1)
Dim num3 As Integer = 0
Do While (num3 < textArray13.Length)
Dim text1 As String = textArray13(num3)
Dim item1 As New WPAMenuItem(Me, text1)
item2.MenuItems.Add(item1)
num3 += 1
Loop
item2.Update()
menu.MenuItems.Add(item2)
End If
num1 += 1
num2 = (num2 * 2)
Loop
End Sub
Public Function CurrEdit() As WPDLLInt Implements WPDynamic.IGetCurrEditor.CurrEdit
Return Me.WpdllInt1
End Function
Public Sub New()
' WPDLLInt.SetDLLName(My.Settings.TDPath) not required in demo
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'WPDLLInt.SetDLLName("{hkcu}Software\\MyCompany\\TextDynamic\\path")
Me.WpdllInt1.SetLayout("buttons.pcc", "")
Me.WpdllInt1.SetEditorMode(EditorMode.wpmodSingleEditor, (EditorXMode.wpmodexPDFExport Or (EditorXMode.wpmodexTables Or (EditorXMode.wpmodexSpellcheck Or EditorXMode.wpmodexToolbarLG))), (EditorGUI.wpguiPanelH1 Or (EditorGUI.wpguiHorzScrollBar Or (EditorGUI.wpguiVertScrollBar Or EditorGUI.wpguiRuler))), EditorGUI.wpguiDontSet)
Dim myMainMenu As New MainMenu
myMainMenu.MenuItems.Clear() ' Start from scratch!
Me.UpdateMenu(myMainMenu, (wpaMenuCaps.wpaDropDownMenuInfo Or wpaMenuCaps.wpaDropDownMenuTable Or wpaMenuCaps.wpaDropDownMenuExtras Or wpaMenuCaps.wpaDropDownMenuFormat Or wpaMenuCaps.wpaDropDownMenuInsert Or wpaMenuCaps.wpaDropDownMenuView Or wpaMenuCaps.wpaDropDownMenuEdit Or wpaMenuCaps.wpaDropDownMenuFile))
Me.Menu = myMainMenu
End Sub
Private Sub WpdllInt1_OnUpdateGUI_1(ByVal Sender As System.Object, ByVal Editor As System.Int32, ByVal UpdateFlags As System.Int32, ByVal StateFlags As System.Int32, ByVal PageNr As System.Int32, ByVal PageCount As System.Int32, ByVal LineNr As System.Int32) Handles WpdllInt1.OnUpdateGUI
Me.stPage.Text = (Convert.ToString(PageNr) & "/"c & Convert.ToString(PageCount))
Me.stLine.Text = ("Line " & Convert.ToString(LineNr))
Me.stIns.Text = IIf(((StateFlags And 2) <> 0), "INS", "")
End Sub
Private Sub WpdllInt1_OnShowHint(ByVal Sender As System.Object, ByVal X As System.Int32, ByVal Y As System.Int32, ByVal Hint As System.String, ByRef Ignore As System.Boolean) Handles WpdllInt1.OnShowHint
Me.stHint.Text = Hint
Ignore = True
End Sub
End Class
Alles anzeigen