twinBASIC Update: June 24, 2024

Highlights include a new multi-line caption-editing dialog, implementation of several missing VB6 control properties, and advanced pointer handling via CType(Of ).

twinBASIC Update: June 24, 2024

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 Monday, 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, please leave a comment below.

Here are some links to get involved with the project:


Highlights

Multi-Line Caption Editing Dialog Box

The Caption property for Labels, Buttons, CheckBoxes, etc. now includes a multi-line editor dialog box which can be opened via the ellipsis button as shown below:

New Properties Added

Support for the following properties was added this week:

  • CommandButton.Default: This property designates a CommandButton as the default action button, making it respond to the Enter key.
  • CommandButton.Cancel: This property marks a CommandButton as the cancel button, allowing it to be triggered by the Esc key.
  • UserControl.DefaultCancel: When DefaultCancel is set to True, pressing the Esc key while the form is active will trigger the default cancel action associated with the user control.
  • Label.VerticalAlignment: This property sets the vertical alignment of the text within the Label, with the default being Top.
  • Label.LineSpacing: This property controls the spacing between lines of text within the Label, measured in twips, with a default value of 0.

Discord Chat Summary

* Auto-generated via Claude-2-100k on poe.com

twinBASIC Development Update: June 15-21, 2024

This week in the twinBASIC general channel, the community discussed various aspects of the language's development, including bug fixes, feature requests, and user experiences. Below are the key points from the conversations:

  • Overloaded Methods: A user experienced confusion with overloaded methods and resolved an issue related to variable naming inconsistencies.
  • Command Button Properties: Wayne's update on command button properties received positive feedback for its utility.
  • Add-in Development: There was a detailed discussion about iterating over controls in the active designer form, with suggestions on using JSON parsing as a workaround.
  • Installation Issues: Users discussed problems related to installing new versions of twinBASIC without deleting previous versions, leading to bugs. A suggestion was made to update the installation FAQ to address this.
  • Regression Bugs: The community clarified the concept of regression bugs, emphasizing their inevitability in large projects and the importance of automated tests.
  • TreeView Control: Issues were reported with the TreeView control, specifically regarding mouse event handling and ImageList initialization.
  • Dispinterface Support: There was a request to add native dispinterface support, which Wayne acknowledged and added to the tracking system.
  • CType Enhancements: Users explored advanced uses of the CType function for pointer manipulation, highlighting its potential for complex data structures.
  • Generic Classes: A user shared a generic class example that led to discussions about type inference and compile-time type checks.
  • Array Indexing with LongLong: A potential bug was reported regarding array indexing with a LongLong variable, with a follow-up to check if it persists in the latest beta.
  • TextBox Property Issue: An issue was raised about the TextBox control not updating its text property correctly when using the ENTER or TAB keys.

Conclusion

This week's discussions in the twinBASIC general channel highlighted ongoing improvements and user experiences with the language. Key themes included resolving installation issues, addressing regression bugs, and enhancing support for advanced features like dispinterfaces and CType conversions. The community continues to actively contribute to the development process, providing valuable feedback and suggestions.


twinBASIC Documentation Update: June 15-21, 2024

This week in the twinBASIC docs channel, there were a few key updates and contributions to the project's documentation. Below are the highlights:

  • Wiki Updates:
    • Pointer Functionality: New sections were added to the wiki covering the use of CType(Of ) for pointer functionality.
    • Strict Mode Warnings: Documentation now includes information on the equivalent warnings in Strict Mode and how to use CType to avoid them.
    • Project Explorer View: A new section has been added detailing the new project explorer view.
    • Label Properties and DLLStackCheck: Brief additions were made to list the new label properties and the dllstackcheck attribute.
  • Transparency Enhancements: The recent transparency enhancements still need to be documented. Contributions from others are welcome.

Conclusion

This week's documentation efforts focused on updating the wiki with new features and improvements in twinBASIC. The community continues to play a vital role in keeping the documentation current and comprehensive.

Around the Web

Enhanced Pointer Support

The recently released CType(Of ) function has been expanded to support more complex scenarios, as fafalone noted in a VBForums post:

I think this new feature deserves it's own post as I'm super excited about it.. last week, tB introduced the CType(Of x) operator for explicit conversions. At first the usage was narrow, just for suppressing new "strict mode" warnings about already-permitted implicit conversions.

But today it got supercharged into a revolutionary new way for the VBx language to manipulate UDTs by pointer. Here's the new features wiki entry I wrote for it:

The CType(Of <type>) operator specifies an explicit intent to cast one type to another. This can be used for casting LongPtr (or Long on 32bit/LongLong on 64bit) to a custom user-defined type, with or without making a copy of it, depending on the usage. This allows not just for casting directly without a CopyMemory call, but also, setting the members of a UDT represented only by a pointer, without copying memory back and forth.


The full wiki entry includes several sample functions demonstrating usage.  This new feature will be most useful when working with Windows APIs, which require heavy usage of pointers (compared to typical VB6\VBA code).

Changelog

Here are the updates from the past week.  You can also find this information by visiting the GitHub twinBASIC Releases page.

Releases · WaynePhillipsEA/twinbasic
Contribute to WaynePhillipsEA/twinbasic development by creating an account on GitHub.

ChatGPT Changelog Summary

* Auto-generated via ChatGPT, sorted in order of ChatGPT's opinion of "most impactful changes."

Here are some of the most notable updates in the latest twinBASIC changelog:

  • Added new properties for enhanced UI control: Support for CommandButton.Default, CommandButton.Cancel, UserControl.DefaultCancel, and UserControl Ambient DisplayAsDefault properties have been integrated, enhancing the ability to manage default button behaviors in a modern way.
  • Improved modern ActiveX control integration: The [CompileIf] attribute is now allowed on class fields, facilitating conditional inclusion of Default/Cancel properties in ActiveXExtender.
  • Enhanced IDE features: Multi-line support for Caption properties in Label, CommandButton, CheckBox, and OptionButton controls, along with multi-line support for ToolTipText properties.
  • Label control enhancements: New properties for Label including VerticalAlignment (default Top) and LineSpacing (in twips, default 0) have been added.
  • Streamlined project management: The IDE now automatically attempts recovery of a corrupt twinproj file and has made the New project options modal dialog cancelable for better user experience.
  • Compatibility improvements: A breaking change ensures native TreeView and ListView events now use ByRef rather than ByVal arguments to align with MS common controls, enhancing compatibility.

WARNING: The following issues are present in BETA builds 546 - 569 (the latest build as of publication):

  • there are known memory leaks in these versions, so memory usage will be higher than normal

BETA 558

  • added: support for CommandButton.Default property
  • added: support for CommandButton.Cancel property
  • added: support for UserControl.DefaultCancel property
  • added: support for UserControl Ambient DisplayAsDefault property
  • improved: [CompileIf] attribute is now allowed on class fields, used in ActiveXExtender to conditionally include Default/Cancel properties

BETA 559

  • fixed: (regression in latest betas) FileListBox could not be used [ MKL, discord ]
  • fixed: (IDE) hover popup for constants would output the description attribute twice [ fafalone, discord ]
  • fixed: (IDE) first click on form designer would not allow drag move/resize [ sokinkeso, discord ]
  • improved: (IDE) persisted JSON (forms, settings, etc) now uses CrLf linefeeds [ GCUser99, discord ]

BETA 560

  • fixed: some issues regarding mouse events and the internal OLE_ param handling [ https://github.com//issues/1835 ]

BETA 561

  • fixed: some codegen edge case errors when array-bounds checking is disabled [ baka, discord ]
  • fixed: Unload form statement within the same Form Load event would cause repeated loading of the form

BETA 562

  • fixed: ParamArray variant copy issue [ fafalone, discord ]

BETA 563

  • changed: (breaking change) native TreeView and ListView MouseUp/MouseMove/MouseDown/KeyUp/KeyDown events to use ByRef rather than ByVal arguments to match the MS common controls [ fafalone, discord ]
  • fixed: accessing an array element with a LongLong index variable on Win64 would trigger a compiler error in recent builds [ fafalone, discord ]

BETA 564

  • fixed: malformed VERSIONINFO block in generated exes, causing some programs like SystemInformer to report the version info strings incorrectly [ fafalone, discord ]
  • improved: tightened up end-block-completion rules to avoid the IDE inserting end-blocks in some inappropriate places [ FullValueRider, discord ]
  • fixed: lightweight controls would not receive Click events if the container control ScaleMode was not set to Twips [ fafalone, discord ]
  • added: Label.VerticalAlignment property (default Top)
  • added: Label.LineSpacing property (in twips, default 0)

BETA 565

  • fixed: (regression since BETA 556) accessing UDT members with array-like syntax was wrongly enforcing implicit CLng() on the passed argument [ Antix, vbforums ]

BETA 566

  • fixed: (IDE) Project > 'Open Project Folder' menu option would throw an internal error for an unsaved project [ fafalone, discord ]
  • fixed: (IDE) New project options modal dialog is now cancelable [ wqweto, discord ]
  • added: support for CommandButton.[_Default] property [ https://github.com//issues/1188 ]
  • fixed: (regression since BETA 558) ActiveX 'shutdown' error [ https://github.com//issues/1865 ]
  • improved: (IDE) Label/CommandButton/CheckBox/OptionButton Caption properties now offer multi-line support in the property sheet by using the ellipses button

BETA 567

  • improved: ToolTipText properties on builtin controls now support multi-line [ https://github.com//issues/1318 ]

BETA 568

  • improved: CType() now allows for converting LongPtr to UDT types [ fafalone, discord ]
  • fixed: some codegen errors involving Err.Raise and non simple args [ wqweto, discord ]

BETA 569

  • fixed: IDE will now attempt recovery of a corrupt twinproj file automatically [ fafalone, discord ]
  • fixed: conflict with internal 'Init' method in forms is now avoided [ fafalone, discord ]
  • fixed: (regression since BETA 424) errors occuring inside tB class methods, originating from external COM callers would wrongly trigger an unhandled error [ https://github.com//issues/1856 ]

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