logo WinWrap®

Show a WinForm Dialog from your WinWrap Basic Script

WinWrap® Basic is an embedded language control available for .NET/COM 32/64 bit Windows applications. The WinWrap® Basic Component is compatible with VBA, Sax Basic, VB.NET and Visual Basic 6.0 style scripts.

Display custom WinForm Dialogs from WinWrap® Basic scripts. Incorporate any WinForm control. Show custom user interfaces for specific clients.

Use Custom Windows Dialogs with your WinWrap® Basic Application

  • Utilize any Windows UI Control
  • Works with .NET, WPF, and COM applications
  • Dynamically display custom WinForms
  • Implement custom user interfaces for specific clients
  • Access host application specific extensions
  • Requires WinWrap® Basic with WWB-NET scripting option

WinForms Hello World Dialog Example

WinWrap® Basic WinForm HelloWorld! Example

Use Visual Studio or Visual Studio Express to define the visual layout of the desired Winform dialog.

Visual Studio HelloDialog ClassLibrary

HelloDialog.wwd

  • Declare the dialog and .NET framework control variables
  • Create the Hello Dialog object and bind to the dialog variables
  • Bind the .NET framework control variables to the dialog elements
  • Show the WinForm HelloDialog
  • Script the desired behavior in the events
HelloWorld Script References
'#Language "WWB.NET" Imports System.Windows.Forms Imports System.Reflection ' Declare the dialog and .NET framework control variables Dim WithEvents helloDialog As Form Dim WithEvents textbox1 As TextBox Dim WithEvents button1 As Button Dim WithEvents exitMenuItem As ToolStripMenuItem Sub Main() ' Create the Hello Dialog object Dim assemblyPath As String = MacroDir & "ClassLibrary1inReleaseClassLibrary1.dll" Dim assemblyClassLibrary1 As Assembly = Assembly.LoadFrom(assemblyPath) Dim typeHelloDialog As System.Type = assemblyClassLibrary1.GetType("ClassLibrary1.HelloDialog") Using helloDialogResource As Form = System.Activator.CreateInstance(typeHelloDialog) helloDialog = helloDialogResource ' Bind to the dialog variables textbox1 = helloDialog.Controls("TextBox1") button1 = helloDialog.Controls("Button1") exitMenuItem = helloDialog.Controls("MenuStrip1").Items("FileToolStripMenuItem").DropDownItems("ExitToolStripMenuItem") ' Show the WinForm HelloDialog helloDialog.show() While helloDialog.Visible Wait 0.1 End While End Using ' call helloDialogResource.Dispose End Sub ' Handle the Button1 click event Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click MsgBox(button1.Text & " " & textbox1.Text) End Sub ' Handle the "Exit MenuItem" click event Private Sub exitMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitMenuItem.Click helloDialog.Close() End Sub

Running the HelloDialog.wwd Script

Display the Hello World Dialog

You can download HelloDialog.zip clicking the following link: WinWrap® Basic Windows Hello Dialog! example. Then open the HelloDialog.wwd macro with WinWrap® Director. WinWrap® Director is part of the WinWrap® Basic Scripting evaluation product. You can modify the ClassLibrary1.dll which defines the HelloDialog with Visual Studio 2010 or Visual Studio Express.

Copyright Polar Engineering, Inc.