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.
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:
- twinBASIC Installation Guide
- GitHub Issue Tracker (report bugs)
- twinBASIC Discord Server (chat about the project)
Highlights
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 0.0.13.0 of the WinNativeForms package added a progress bar control:
Image Control Added to WinNativeForms Package
Version 0.0.15.0 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") .Show 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.
Changelog
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]
- (WinNativeForms v0.0.16.0) changed: all toolbox images, kindly provided by @Robin1997#8689 over on Discord. Thanks Rob!
- (WinNativeForms v0.0.16.0) fixed: Form.hWnd property is now exposed [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1044075841 ]
- (WinNativeForms v0.0.16.0) added: Image.Border property [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1045270615 ]
- (WinNativeForms v0.0.16.0) fixed: changing the Image.Picture property at runtime now triggers a Refresh()
- improved: Global.LoadPicture now also uses the passed in Size/Depth properties when given a byte-array stream [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1045039209 ]
- fixed: reported byte size of Picture property was not shown correctly in the form designer due to the new base64 encoding of byte-arrays in JSON
- fixed: an image control without having a picture set was casuing JSON deserialization errors
- fixed: missing hCursor on the ThunderForm registered window class [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1044073873 ]
- fixed: UDT Members Not Recognized in With Blocks with Line Numbers [ https://github.com/WaynePhillipsEA/twinbasic/issues/744 ]
- fixed: added CS_DBLCLKS to created subclassed controls to ensure double click events get fired
[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]
- fixed: For-Each edge case [ https://github.com/WaynePhillipsEA/twinbasic/issues/739 ]
- (WinNativeForms v0.0.14.0) fixed: WM_SETFONT handling to match VB6 [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1042747336 ]
- (WinNativeForms v0.0.14.0) improved: changed CB_GETCOMBOBOXINFO to use WindowsAPI.GetComboBoxInfo for Win2K support [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1042674289 ]
- (WinNativeForms v0.0.14.0) fixed: changed ListBox.DblClick event to fire from LBN_DBLCLK rather than WM_LBUTTONDBLCLK [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1042670789 ]
- (WinNativeForms v0.0.14.0) reverted: IBeam change from v0.0.12.0, and fixed the WM_SETCURSOR handling [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1042665044 ]
- (WinNativeForms v0.0.14.0) improved: added ListBox item checkbox padding to better match VB6 [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1042801078 ]
[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]
- renamed:
WindowsControlPackage
toWinFormsPackage
- improved:
WinFormsPackage
andCustomControlsPakage
are now deployed as compiler built-in packages, rather than through TWINSERV (no manual updating required) - fixed:
WinFormsPackage
; TextBox MultiLine mode fixes [ https://github.com/WaynePhillipsEA/twinbasic/issues/734 ] - fixed:
WinFormsPackage
; ComboBox Sorted property was not effective [ https://github.com/WaynePhillipsEA/twinbasic/issues/706#issuecomment-1038484785 ] - improved: all Samples now reference either the
WinFormsPackage
or theCustomControlsPackage
, except for thePackage
sample