Hi All,
Life has been pretty busy recently and I've had to shelve my personal programming projects for the moment.
It's simple enough to do the DLL. Simply make a class and use all static functions. You will then need to run another program to fix it into a standard DLL
The class for the DLL in my demo:
and a short BlitzPlus program to do the conversion of the DLL into a standard Blitzable DLL:
It's a bit rough around the edges, but it does the job.
Life has been pretty busy recently and I've had to shelve my personal programming projects for the moment.
It's simple enough to do the DLL. Simply make a class and use all static functions. You will then need to run another program to fix it into a standard DLL
The class for the DLL in my demo:
Imports System.Windows.Forms Imports System.Drawing Public Class Class1 Inherits System.Windows.Forms.Form Structure eStack Dim Gadget As Integer Dim EventType As Integer Dim EventASC As Integer Dim EventScan As Integer End Structure Structure ControlInfo Dim repaintme As Integer End Structure Shared Gadget(1) As Object 'Control Shared stat(1) As ControlInfo Shared GadgetCount As Integer Shared EventStack(1000) As eStack Shared EventPointer As Integer Shared Function FreeG() As Integer Dim ind As Integer For ind = 1 To UBound(Gadget) If Gadget(ind) Is Nothing Then Return ind End If Next ReDim Preserve Gadget(UBound(Gadget) + 1) : ReDim Preserve stat(UBound(stat) + 1) Return UBound(Gadget) End Function Shared Function GetHandle(ByVal gad As Integer) As Integer Dim c As Control Dim i As Int32 c = Gadget(gad) i = c.Handle.ToInt32 Return i End Function Shared Sub HideGUI(ByVal gad As Integer) Dim holdc As Control Dim holdm As MenuItem If Gadget(gad) Is Nothing Then Exit Sub Dim ListType As String ListType = Gadget(gad).GetType.Name Select Case ListType Case "MyMenuItem" holdm = Gadget(gad) holdm.Visible = False Case Else holdc = Gadget(gad) holdc.Visible = False End Select End Sub Shared Sub ShowGUI(ByVal gad As Integer) Dim holdc As Control Dim holdm As MenuItem If Gadget(gad) Is Nothing Then Exit Sub Dim ListType As String ListType = Gadget(gad).GetType.Name Select Case ListType Case "MyMenuItem" holdm = Gadget(gad) holdm.Visible = True Case Else holdc = Gadget(gad) holdc.Visible = True End Select End Sub Shared Sub SetAnchor(ByVal gad As Integer, ByVal Left As Integer, ByVal right As Integer, ByVal top As Integer, ByVal bottom As Integer) Dim ank As Integer If Left <> 0 Then ank += AnchorStyles.Left If right <> 0 Then ank += AnchorStyles.Right If top <> 0 Then ank += AnchorStyles.Top If bottom <> 0 Then ank += AnchorStyles.Bottom Gadget(gad).Anchor = ank End Sub Shared Sub DockLeft(ByVal gad As Integer) Gadget(gad).Dock = DockStyle.Left End Sub Shared Sub DockTop(ByVal gad As Integer) Gadget(gad).Dock = DockStyle.Top End Sub Shared Sub DockRight(ByVal gad As Integer) Gadget(gad).Dock = DockStyle.Right End Sub Shared Sub DockBottom(ByVal gad As Integer) Gadget(gad).Dock = DockStyle.Bottom End Sub Shared Sub DockFill(ByVal gad As Integer) Gadget(gad).Dock = DockStyle.Fill End Sub Shared Sub DockNone(ByVal gad As Integer) Gadget(gad).Dock = DockStyle.None End Sub Shared Function GetIndex(ByVal Gad As Integer) As Integer If Gadget(Gad) Is Nothing Then Exit Function Dim ListType As String ListType = Gadget(Gad).GetType.Name Select Case ListType Case "ListBox" Dim list As ListBox list = Gadget(Gad) Return list.SelectedIndex Case "CheckedListBox" Dim list As CheckedListBox list = Gadget(Gad) Return list.SelectedIndex Case "ComboBox" Dim list As ComboBox list = Gadget(Gad) Return list.SelectedIndex End Select End Function Shared Sub SetIndex(ByVal Gad As Integer, ByVal index As Integer) If Gadget(Gad) Is Nothing Then Exit Sub Dim ListType As String ListType = Gadget(Gad).GetType.Name Select Case ListType Case "ListBox" Dim list As ListBox list = Gadget(Gad) list.SelectedIndex = index Case "CheckedListBox" Dim list As CheckedListBox list = Gadget(Gad) list.SelectedIndex = index Case "ComboBox" Dim list As ComboBox list = Gadget(Gad) list.SelectedIndex = index End Select End Sub Shared Function AddItem(ByVal list As Integer, ByVal item As String) As Integer If Gadget(list) Is Nothing Then Exit Function Dim ListType As String ListType = Gadget(list).GetType.Name Select Case ListType Case "ListBox" Dim L As ListBox L = Gadget(list) L.Items.Add(item) Return L.Items.Count - 1 Case "CheckedListBox" Dim L As CheckedListBox L = Gadget(list) L.Items.Add(item) Return L.Items.Count - 1 Case "ComboBox" Dim L As ComboBox L = Gadget(list) L.Items.Add(item) Return L.Items.Count - 1 End Select End Function Shared Sub RemoveItem(ByVal list As Integer, ByVal index As Integer) If Gadget(list) Is Nothing Then Exit Sub Dim ListType As String ListType = Gadget(list).GetType.Name Select Case ListType Case "ListBox" Dim L As ListBox L = Gadget(list) If index < -1 Or index > l.Items.Count - 1 Or l.Items.Count < 1 Then Exit Sub If index = -1 Then If l.SelectedIndex < 0 Then Exit Sub L.Items.removeat(l.Selectedindex) Else L.Items.removeat(index) End If Case "CheckedListBox" Dim L As CheckedListBox L = Gadget(list) If index < -1 Or index > l.Items.Count - 1 Or l.Items.Count < 1 Then Exit Sub If index = -1 Then If l.SelectedIndex < 0 Then Exit Sub L.Items.removeat(l.Selectedindex) Else L.Items.removeat(index) End If End Select End Sub Shared Sub SetGadgetBorder(ByVal gad As Integer, ByVal bord As Integer) If Gadget(gad) Is Nothing Then Exit Sub Dim ListType As String ListType = Gadget(gad).GetType.Name Select Case ListType Case "PictureBox" If bord < 0 Or bord > 2 Then Exit Sub Dim L As PictureBox L = Gadget(gad) L.BorderStyle = bord Case "Panel" If bord < 0 Or bord > 2 Then Exit Sub Dim L As Panel L = Gadget(gad) L.BorderStyle = bord Case "Form" If bord < 0 Or bord > 6 Then Exit Sub Dim L As Form L = Gadget(gad) L.FormBorderStyle = bord End Select End Sub Shared Sub fclose(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Dim o As Control o = sender AddEvent(o, 9, 0, 0) ' Closing form e.Cancel = True End Sub Shared Sub MyKeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim o As Control o = sender AddEvent(o, 2, Asc(e.KeyChar), 0) ' 1 - Keypress End Sub Shared Sub MyKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Dim o As Control o = sender AddEvent(o, 1, 0, e.KeyCode) ' 5 - KeyDown End Sub Shared Sub MyKeyUP(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Dim o As Control o = sender AddEvent(o, 3, 0, e.KeyCode) ' 6 - KeyUp End Sub Shared Sub MyClick(ByVal sender As Object, ByVal e As System.EventArgs) Dim o As Object o = sender AddEvent(o, 4, 0, 0) End Sub Shared Sub MyMouseIn(ByVal sender As Object, ByVal e As System.EventArgs) Dim o As Control o = sender AddEvent(o, 6, 0, 0) End Sub Shared Sub MyListChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim o As Control o = sender AddEvent(o, 10, 0, 0) End Sub Shared Sub MyMouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim o As Control o = sender AddEvent(o, 7, e.X, e.Y) End Sub Shared Sub MyMouseup(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim o As Control o = sender AddEvent(o, 11, e.X, e.Y) End Sub Shared Sub MyMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim o As Control o = sender AddEvent(o, 12, e.X, e.Y) End Sub Shared Sub MyMouseOut(ByVal sender As Object, ByVal e As System.EventArgs) Dim o As Control o = sender AddEvent(o, 8, 0, 0) End Sub Shared Sub MyDoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Dim o As Control o = sender AddEvent(o, 5, 0, 0) '4 ' Double Click End Sub Shared Sub MoveGadget(ByVal GNO As Integer, ByVal x As Integer, ByVal y As Integer) Gadget(GNO).Left = x Gadget(GNO).Top = y End Sub Shared Sub SizeGadget(ByVal GNO As Integer, ByVal w As Integer, ByVal h As Integer) Gadget(GNO).Width = w Gadget(GNO).Height = h End Sub Shared Function GetGadgetX(ByVal gad As Integer) As Integer Return Gadget(gad).Left End Function Shared Function GetGadgetY(ByVal gad As Integer) As Integer Return Gadget(gad).Top End Function Shared Function GetGadgetW(ByVal gad As Integer) As Integer Return Gadget(gad).Width End Function Shared Function GetGadgetH(ByVal gad As Integer) As Integer Return Gadget(gad).Height End Function Shared Sub SetBackColor(ByVal gad As Integer, ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) Dim c As Control Dim clr As New System.Drawing.Color clr = Color.FromArgb(r, g, b) c = Gadget(gad) c.BackColor = clr End Sub Shared Sub SetForeColor(ByVal gad As Integer, ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) Dim c As Control Dim clr As New System.Drawing.Color clr = Color.FromArgb(r, g, b) c = Gadget(gad) c.ForeColor = clr End Sub Shared Function Message(ByVal tex As String, ByVal caption As String, ByVal buts As Integer) As Integer Return MessageBox.Show(tex, caption, buts) End Function Shared Function GetEvent(ByRef x As eStack) As Integer Dim r As Integer If EventPointer > 0 Then x.Gadget = EventStack(1).Gadget x.EventType = EventStack(1).EventType x.EventASC = EventStack(1).EventASC x.EventScan = EventStack(1).EventScan 'EventStack(0) = Nothing For r = 0 To EventPointer EventStack(r) = EventStack(r + 1) Next 'EventStack(EventPointer) = Nothing EventPointer -= 1 Application.DoEvents() Return 1 Else x.Gadget = 0 x.EventType = 0 x.EventASC = 0 x.EventScan = 0 Application.DoEvents() Return 0 End If End Function 'Shared Function GetEvent(ByRef gadget As Integer, ByRef EventType As Integer, ByRef EventASC As Integer, ByRef EventScan As Integer) As Integer ' Dim r As Integer ' Application.DoEvents() ' If EventPointer > 0 Then ' gadget = EventStack(1).Gadget ' EventType = EventStack(1).EventType ' EventASC = EventStack(1).EventASC ' EventScan = EventStack(1).EventScan ' 'EventStack(0) = Nothing ' For r = 0 To EventPointer ' EventStack(r) = EventStack(r + 1) ' Next ' 'EventStack(EventPointer) = Nothing ' EventPointer -= 1 ' Application.DoEvents() ' Return 1 ' Else ' Return 0 ' Application.DoEvents() ' End If 'End Function Shared Sub AddEvent(ByVal o As Object, ByVal Etype As Integer, ByVal EASC As Integer, ByVal ESCAN As Integer) If EventPointer >= 1000 Then Exit Sub EventPointer += 1 EventStack(EventPointer).Gadget = CInt(Val(o.Name)) EventStack(EventPointer).EventType = Etype EventStack(EventPointer).EventASC = EASC EventStack(EventPointer).EventScan = ESCAN End Sub Shared Function AddForm(ByVal tex As String, ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer, ByVal Border As Integer) As Integer Dim HoldForm As Form GadgetCount = FreeG() Gadget(GadgetCount) = New Form If parent <> 0 Then HoldForm.Parent = Gadget(parent) HoldForm = Gadget(GadgetCount) HoldForm.SuspendLayout() HoldForm.Top = -1000 HoldForm.Left = -1000 HoldForm.Show() HoldForm.Visible = False HoldForm.AutoScaleBaseSize = New System.Drawing.Size(W, H) HoldForm.ClientSize = New System.Drawing.Size(W, H) HoldForm.Name = CStr(GadgetCount) HoldForm.Text = tex HoldForm.Visible = True HoldForm.Top = Y HoldForm.Left = X HoldForm.FormBorderStyle = Border HoldForm.ResumeLayout() AddHandler HoldForm.KeyDown, AddressOf MyKeyDown AddHandler HoldForm.MouseEnter, AddressOf MyMouseIn AddHandler HoldForm.MouseLeave, AddressOf MyMouseOut AddHandler HoldForm.MouseMove, AddressOf MyMouseMove AddHandler HoldForm.KeyUp, AddressOf MyKeyUP AddHandler HoldForm.Closing, AddressOf fclose AddHandler HoldForm.Click, AddressOf MyClick AddHandler HoldForm.DoubleClick, AddressOf MyDoubleClick Return GadgetCount End Function Shared Function AddListBox(ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As ListBox GadgetCount = FreeG() Gadget(GadgetCount) = New ListBox HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X AddHandler HoldTB.SelectedIndexChanged, AddressOf MyListChanged AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.DoubleClick, AddressOf MyDoubleClick HoldTB.ResumeLayout() Return GadgetCount End Function Shared Function AddCheckListBox(ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As CheckedListBox GadgetCount = FreeG() Gadget(GadgetCount) = New CheckedListBox HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X AddHandler HoldTB.SelectedIndexChanged, AddressOf MyListChanged AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.DoubleClick, AddressOf MyDoubleClick HoldTB.ResumeLayout() Return GadgetCount End Function Shared Sub DeleteGadget(ByVal g As Integer) If Gadget(g) Is Nothing Then Exit Sub Gadget(g).Dispose() Gadget(g) = Nothing End Sub Shared Sub SetGadgetTxt(ByVal gad As Integer, ByVal tex As String) Gadget(gad).Text = tex End Sub Shared Function GetGadgetTxt(ByVal gad As Integer) As String Return Gadget(gad).Text End Function Shared Function AddTextBox(ByVal tex As String, ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer, ByVal multi As Integer) As Integer Dim HoldTB As TextBox GadgetCount = FreeG() Gadget(GadgetCount) = New TextBox HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Text = tex HoldTB.Multiline = multi HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.Click, AddressOf MyClick HoldTB.ResumeLayout() Return GadgetCount End Function Shared Function AddLabel(ByVal tex As String, ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As Label GadgetCount = FreeG() Gadget(GadgetCount) = New Label HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Text = tex HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X HoldTB.FlatStyle = FlatStyle.System HoldTB.ResumeLayout() AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.DoubleClick, AddressOf MyDoubleClick Return GadgetCount End Function Shared Function AddButton(ByVal tex As String, ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As Button GadgetCount = FreeG() Gadget(GadgetCount) = New Button HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Text = tex HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X HoldTB.FlatStyle = FlatStyle.System HoldTB.ResumeLayout() AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick Return GadgetCount End Function Shared Function AddCheckBox(ByVal tex As String, ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As CheckBox GadgetCount = FreeG() Gadget(GadgetCount) = New CheckBox HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Text = tex HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.CheckStateChanged, AddressOf MyClick HoldTB.ResumeLayout() Return GadgetCount End Function Shared Function AddGroupBox(ByVal tex As String, ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As GroupBox GadgetCount = FreeG() Gadget(GadgetCount) = New GroupBox HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Text = tex HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X HoldTB.FlatStyle = FlatStyle.System AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress HoldTB.ResumeLayout() Return GadgetCount End Function Shared Function AddImageBox(ByVal img As String, ByVal mode As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As PictureBox GadgetCount = FreeG() Gadget(GadgetCount) = New PictureBox HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X If img <> "" Then If Dir(img) <> "" Then HoldTB.Image = New Bitmap(img) End If End If HoldTB.SizeMode = mode AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.DoubleClick, AddressOf MyDoubleClick AddHandler HoldTB.Paint, AddressOf MyPaint AddHandler HoldTB.MouseDown, AddressOf MyMouseDown AddHandler HoldTB.MouseUp, AddressOf MyMouseup HoldTB.ResumeLayout() Return GadgetCount End Function Shared Function Repaint(ByVal gad As Integer) As Integer Dim i As Integer i = stat(gad).repaintme stat(gad).repaintme = 0 Return i End Function Shared Sub MyPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) '. stat(CInt(Val(sender.Name))).repaintme = 1 End Sub Shared Function AddPanel(ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As Panel GadgetCount = FreeG() Gadget(GadgetCount) = New Panel HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.DoubleClick, AddressOf MyDoubleClick HoldTB.ResumeLayout() Return GadgetCount End Function Shared Function AddDropDown(ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As ComboBox GadgetCount = FreeG() Gadget(GadgetCount) = New ComboBox HoldTB = Gadget(GadgetCount) HoldTB.Top = -1000 HoldTB.Left = -1000 HoldTB.SuspendLayout() HoldTB.Show() HoldTB.Visible = False If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Name = CStr(GadgetCount) HoldTB.Visible = True HoldTB.Top = Y HoldTB.Left = X HoldTB.DropDownStyle = ComboBoxStyle.DropDownList HoldTB.ResumeLayout() AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.DoubleClick, AddressOf MyDoubleClick AddHandler HoldTB.SelectedIndexChanged, AddressOf MyListChanged Return GadgetCount End Function Shared Function AddSplitter(ByVal X As Integer, ByVal Y As Integer, ByVal W As Integer, ByVal H As Integer, ByVal parent As Integer) As Integer Dim HoldTB As Splitter GadgetCount = FreeG() Gadget(GadgetCount) = New Splitter HoldTB = Gadget(GadgetCount) HoldTB.SuspendLayout() HoldTB.ClientSize = New System.Drawing.Size(W, H) HoldTB.Location = New System.Drawing.Point(X, Y) HoldTB.Show() If parent <> 0 Then HoldTB.Parent = Gadget(parent) HoldTB.Name = CStr(GadgetCount) HoldTB.Visible = True HoldTB.ResumeLayout() AddHandler HoldTB.MouseEnter, AddressOf MyMouseIn AddHandler HoldTB.MouseLeave, AddressOf MyMouseOut AddHandler HoldTB.MouseMove, AddressOf MyMouseMove AddHandler HoldTB.KeyDown, AddressOf MyKeyDown AddHandler HoldTB.KeyUp, AddressOf MyKeyUP AddHandler HoldTB.KeyPress, AddressOf MyKeyPress AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.DoubleClick, AddressOf MyDoubleClick Return GadgetCount End Function Shared Function AddMainMenu(ByVal parent As Integer) As Integer Dim HoldTB As MyMainMenu Dim ParForm As Form GadgetCount = FreeG() Gadget(GadgetCount) = New MyMainMenu HoldTB = Gadget(GadgetCount) HoldTB.Name = CStr(GadgetCount) ParForm = Gadget(parent) ParForm.Menu = HoldTB Return GadgetCount End Function Shared Function AddContextMenu(ByVal parent As Integer) As Integer Dim HoldTB As MyContextMenu Dim ParForm As Control GadgetCount = FreeG() Gadget(GadgetCount) = New MyContextMenu HoldTB = Gadget(GadgetCount) HoldTB.Name = CStr(GadgetCount) ParForm = Gadget(parent) ParForm.ContextMenu = HoldTB Return GadgetCount End Function Shared Function AddMenuItem(ByVal txt As String, ByVal parent As Integer) As Integer Dim HoldTB As MyMenuItem Dim parmen As Menu GadgetCount = FreeG() Gadget(GadgetCount) = New MyMenuItem HoldTB = Gadget(GadgetCount) HoldTB.Name = CStr(GadgetCount) HoldTB.Text = txt parmen = Gadget(parent) parmen.MenuItems.Add(HoldTB) AddHandler HoldTB.Click, AddressOf MyClick AddHandler HoldTB.Popup, AddressOf MyClick Return GadgetCount End Function Shared Function OpenFileDialog(ByVal Caption As String, ByVal InitialPath As String, ByVal Filter As String) As String Dim FileDial As New OpenFileDialog FileDial.Title = Caption FileDial.InitialDirectory = InitialPath FileDial.Filter = Filter FileDial.RestoreDirectory = True FileDial.ShowDialog() Return FileDial.FileName End Function Shared Function SaveFileDialog(ByVal Caption As String, ByVal InitialPath As String, ByVal Filter As String) As String Dim FileDial As New SaveFileDialog FileDial.Title = Caption FileDial.InitialDirectory = InitialPath FileDial.Filter = Filter FileDial.RestoreDirectory = True FileDial.ShowDialog() Return FileDial.FileName End Function Shared Function BrowseFolderDialog(ByVal Caption As String, ByVal InitialPath As String) As String Dim FileDial As New FolderBrowserDialog FileDial.Description = Caption FileDial.SelectedPath = InitialPath FileDial.ShowNewFolderButton = True FileDial.ShowDialog() Application.DoEvents() Return FileDial.SelectedPath End Function End Class
and a short BlitzPlus program to do the conversion of the DLL into a standard Blitzable DLL:
Dim meth$(1000) If CommandLine$()="" Then file$ = ExecuteOpendialog("Select .NET DLL to Convert","","","Dynamic Link Libraries|*.DLL|All Files|*.*") Else file$ = CommandLine$() EndIf If file$="" Then End ChangeDir("C:\NetProjects\DLLTEST") ExecFile ("ILDASM.EXE /OUT:MYIL.IL "+file$) Delay 1000 parseIL() ;ExecFile ("ILASM.EXE /OUT:"+file$+" MYIL2.IL /DLL") ExecFile ("ILASM.EXE /OUT:TeraGUI.DLL MYIL2.IL /DLL") Notify "" CopyFile "C:\NetProjects\DLLTEST\TeraGUI.DLL","C:\MaxProjects\TeraGUI\TeraGUI.DLL" End Function ParseIL() rd = ReadFile("MYIL.IL") If rd = 0 Then End While Eof(rd)=False in$ = ReadLine$(rd) det$ = Upper$(Trim$(in$)) If Left$(det$,7)=".METHOD" Then If getname$(in$)<>"" Then methodcount = methodcount + 1 meth$(methodcount)=GetName$(in$) ;Notify "Method: "+methodcount+" - "+GetName$(in$) EndIf EndIf Wend CloseFile rd rd = ReadFile("MYIL.IL") If rd = 0 Then End wt = WriteFile("MYIL2.IL") While Eof(rd)=False Pass = 0 in$ = ReadLine$(rd) det$ = Upper$(Trim$(in$)) If det$=".CORFLAGS 0X00000001" Then WriteLine wt,".corflags 0x00000002" For mct = 1 To methodcount WriteLine wt,".vtfixup [1] int32 fromunmanaged at VT_"+mct Next For mct = 1 To methodcount WriteLine wt,".data VT_"+mct+" = int32(0)" Next Pass = 1 EndIf If Left$(det$,7)=".METHOD" Then If getname$(in$)<>"" Then mcount = mcount + 1 dname$ = GetName$(in$) WriteLine wt,in$ Repeat og$ = Trim$(ReadLine$(rd)) If og$<>"{" Then WriteLine wt, String$(" ",Instr(in$,"("))+og$ Until og$="{" WriteLine wt,"{" WriteLine wt,".vtentry "+mcount+" : 1" ;mcount WriteLine wt,".export ["+mcount+"] as "+dname$ ReadLine$(rd) pass = 1 EndIf EndIf If pass = 0 Then WriteLine wt,in$ Wend CloseFile rd CloseFile wt End Function Function GetName$(my$) ept = Instr(my$,"(")-1 For a = ept To 1 Step -1 If Mid$(my$,a,1)=" " Then Return Mid$(my$,a+1,ept-a) Next Return "" End Function
It's a bit rough around the edges, but it does the job.