logo WinWrap®

Scripting - Execution and Design

WinWrap® Basic is an embedded macro language component available for .NET and COM 32/64 bit Windows applications. The WinWrap® Basic Component is an alternative to Visual Basic for Applications (VBA), ActiveX (e.g. VBScript, JScript, PerlScript, Rexx-based WSH engines and others), and VSTA for this purpose. The WinWrap® Basic Component is compatible with VBA, Sax Basic, VB.NET and Visual Basic 6.0 style scripts.


  • Execute scripts to handle customized application behavior
  • Edit scripts in design mode
  • Parse script code for future execution
  • Check for parse errors when switching to execution mode

Design Mode

Setting DesignModeVisible to True adds the Design Mode menu choice to the Macro menu and the Design Mode tool to the toolbar.

Example2 - BasicIdeCtl

Handling Design Mode Events

When DesignMode_ changes from True to False the LeaveDesignMode event is fired and when DesignMode_ changes from False to True the EnterDesignMode event is fired. This allows the application to determine the exact meanings of DesignMode_=True and DesignMode_=False. DesignMode_ starts out as True. Your application can set DesignMode_ to False during startup if desired.

private void basicIdeCtl1_LeaveDesignMode(object sender, WinWrap.Basic.Classic.DesignModeEventArgs e) { if (basicIdeCtl1.LoadModule(ScriptPath("Globals"))) { // Load selected script (can access globals loaded above) module_ = basicIdeCtl1.ModuleInstance(ScriptPath(Script), false); } if (module_ == null) { // Can't leave design mode because LoadModule or ModuleInstance were unsuccessful e.Cancel = true; basicIdeCtl1.ExecuteMenuCommand(WinWrap.Basic.CommandConstants.ShowError); basicIdeCtl1.UnloadModule(ScriptPath("Globals")); } } private void basicIdeCtl1_EnterDesignMode(object sender, WinWrap.Basic.Classic.DesignModeEventArgs e) { if (module_ != null) { module_.Dispose(); module_ = null; basicIdeCtl1.UnloadModule(ScriptPath("Globals")); } }

Use of DesignMode_ to check for parse errors

The design mode button shows the design state: down when DesignMode_ is True and up whe DesignMode_ is False. Clicking on the down button fires the LeaveDesignMode event. The application determines exactly what needs to happen when leaving design mode and can cancel the attempt to leave. In the screen shot below the application has canceled leaving design mode due to a parsing error.

parse error

See WinWrap Examples for instructions on how to download and run "Example 2 - TabControl".

Copyright Polar Engineering, Inc.