twinBASIC Update: February 20, 2022

Highlights include checkbox-style list boxes, native Winforms progress bar and image controls, and an option to align controls to grid in the form designer.

twinBASIC Update: February 20, 2022

On April 23, 2021, I helped Wayne Phillips introduce the world to twinBASIC at the Access DevCon Vienna conference.  I boldly predicted that twinBASIC (along with the Monaco editor) would replace VBA and its outdated development environment by 2025.  With that goal in mind, this weekly update is my attempt to keep the project fresh in the minds of the VBA development community.

Every Sunday, I will be providing updates on the status of the project, linking to new articles discussing twinBASIC, and generally trying to increase engagement with the project.  If you come across items that should be included here, tweet me @NoLongerSet or email me at mike at nolongerset dot com.

Here are some links to get involved with the project:


CheckBox Style Support in ListBox Control

Version 0.14.20 adds support for checkboxes in the twinBASIC list box control:

To get this effect, set the ListBox style to vbListBoxCheckbox.

ProgressBar Control Added to WinNativeForms Package

Version of the WinNativeForms package added a progress bar control:

Image Control Added to WinNativeForms Package

Version of the WinNativeForms package added an Image control.

Check out these related notes from Wayne:

Some notes on the initial implementation of Image control:
• not currently a windowless control like VB6
• the form designer supports PNG files, but converts them to BITMAP, and it is the BITMAP that gets stored
• there's currently an issue where if you don't populate the Image control with a picture, it sometimes shows a JSON error for that control in the designer
• transparent GIFs are supported
• it is DPI aware

Align Controls to Grid Option in Form Designer

The "Align Controls To Grid" option is now available in v0.14.28:

WinNativeForms Package Updates

The WindowsControl package has been renamed to WinNativeForms package and is now deployed as a compiler-built-in package:

Around the Web

Using Class Constructors with Forms in twinBASIC

Over on the Windows Forms GUI Support thread in GitHub, someone asked the following question:

Help Please... In the class (,twin) associated with the tbform there is a sub New. What is this and how does it relate to the familiar Form_Load and Form_Activate events etc???

I think this is a question many others may have, and I also found Wayne's answer both illuminating and thought-provoking:

Sub New is just the equivalent of Class_Initialize. But you can also expand it to create parameterized constructors. e.g.

Sub New()    ' equivalent to Class_Initialize
End Sub

Sub New(Caption As String)
   Me.Caption = Caption
End Sub

Which you then might use like so:

With New MyForm("my form title")
End With

In Access, I commonly pass a parse-able string as the OpenArgs parameter of DoCmd.OpenForm.  Wayne's technique would be a type-safe replacement for the OpenArgs approach, which has the huge benefit of converting potential run-time errors to compile-time errors.

VB6 Form Import on the Horizon

Wayne has mentioned in both the Discord server and the GitHub project page that he will be working on VB6 form import support in the next week or two.

Changes Not Shown When Launching Forms in Debug Mode

There is a known issue where changes made in form design view are not automatically applied when opening the form via Debug Mode:

Describe the bug
At the moment, if you have unsaved changes in a form designer, and then run code in the debug session that launches the form, then you will get the last saved version of the form design appear.

Additional context
There are currently two workarounds.  Either use the big red 'PREVIEW' button in the form designer, which does sync the unsaved form design before displaying it, OR save the form changes before running code in the debugger that opens forms.

I expect this will be fixed shortly.  In the meantime, I think this behavior could be frustrating for an unsuspecting developer, so I thought it was worth highlighting in this weekly update.


Here are the updates from the past week.  You can also find this information by installing the twinBASIC VS Code extension and clicking on the Changelog tab of the extension page:

[v0.14.28, 20th February 2022]

  • added: 'Align Controls To Grid' option in form designer, saved with form metadata [ Discord: wqweto ]
  • added: 'Grid Width' option in form designer, saved with form metadata
  • added: 'Grid Height' option in form designer, saved with form metadata

[v0.14.27, 19th February 2022]

[v0.14.26, 18th February 2022]

  • fixed: Global.LoadPicture now accepts a byte array stream of file data in the first argument

[v0.14.25, 18th February 2022]

  • (WinNativeForms v0.0.15.0) improved: added initial implementation of Image control
  • improved: JSON serialization of Byte arrays now use Base64 encoding for better JSON efficiency
  • added: Global.LoadPicture now accepts a byte array stream of file data in the first argument

[v0.14.24, 17th February 2022]

[v0.14.23, 17th February 2022]

  • (WinNativeForms v0.0.13.0) added: ProgressBar control
  • (WinNativeForms v0.0.13.0) added: SubClass optional argument to CreateRootWindowElement base functions

[v0.14.22, 16th February 2022]

  • improved: if a [WindowsControl(iconPath)] attribute links to an icon that can't be found, a red placeholder icon will now be used inside the designer
  • fixed: entering bad data into the form designer properties could cause a hard crash of the compiler during deserialization

[v0.14.21, 16th February 2022]

  • fixed: some visual inaccuracies in the form designer when working with WinNativeForms
  • (WinNativeForms v0.0.12.0) fixed: TextBox and ComboBox MousePointer now defaults to IBeam

[v0.14.20, 16th February 2022]

  • fixed: codegen issue on x64 involving floating point numbers when passed as arguments in the XMM2/3 registers
  • renamed: package to WinNativeForms
  • (WinNativeForms v0.0.11.0) fixed: ListBox events not firing due to missing LBS_NOTIFY
  • (WinNativeForms v0.0.11.0) added: ListBox support for vbListBoxCheckbox (checked listbox)
  • (WinNativeForms v0.0.11.0) added: Scroll event support to ComboBox, ListBox, HScrollBar and VScrollBar
  • (WinNativeForms v0.0.11.0) added: internal event of MouseWheel(Delta)
  • (WinNativeForms v0.0.11.0) added: internal event of PreMouseDown(Buttons, Shift, X, Y)
  • (WinNativeForms v0.0.11.0) added: internal event of PreProcessMessage(Msg, wParam, lParam, MutedReturnValue)
  • (WinNativeForms v0.0.11.0) added: internal event of PostProcessMessage(Msg, wParam, lParam)
  • (WinNativeForms v0.0.11.0) added: ListBox.MaxCheckboxSize property (Long)
  • (WinNativeForms v0.0.11.0) added: ListBox.WheelScrollEvent property (Boolean)
  • (WinNativeForms v0.0.11.0) added: ComboBox.WheelScrollEvent property (Boolean)

[v0.14.19, 14th February 2022]

All original code samples by Mike Wolfe are licensed under CC BY 4.0