12114:demo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
12114:demo [2024/04/15 03:54 UTC] – created mwolfe12114:demo [2024/04/15 19:11 UTC] (current) – [Demo Script: DevCon 2024] mike
Line 1: Line 1:
 ====== Demo Script: DevCon 2024 ====== ====== Demo Script: DevCon 2024 ======
  
-Create repo: ''M:\Repos\NLS\DevCon2024\.hg\''+  * I have 25 minutes for the demo portion: 
 +    * 0:01: Download and open twinBASIC 
 +    * 0:02: Customize add-in name and description 
 +    * 0:04: Create the tool window controls 
 +    * 0:05: Edit the Code in myToolWindow 
 +    * 0:07: Test in Access 
 +    * 0:10: Explain Strongly-typed collections and copy ''BuildStronglyTypedCollection()'' function 
 +    * 0:15: Bring in other dependencies 
 +    * 0:16: Test in Access 
 +    * 0:18: Test in Barebones Access 
 +    * 0:22: Convert fafalone's WinDevLib package 
 +    * 0:24: Build 64-bit version 
 +    * 0:25: Explain ''regsvr32'' registration; mention InnoSetup 
 +===== Download and Save Sample Code =====
  
-Open twinBASIC > **Sample 4**+  - Download [[https://github.com/twinbasic/twinbasic/releases/tag/beta-x-0504|twinBASIC BETA 504]] 
 +  - Extract from Zip folder 
 +  - Open twinBASIC > **Sample 4** 
 +  - Enter Project Name: ''Demo2024'' (//Do not put spaces in the name//) 
 +  - Save as: ''%tmp%\Demo2024\Demo2024.twinproj'' 
 +    - Navigate to: ''%tmp%'' 
 +    - Create folder named: ''Demo2024'' 
 +    - Filename: ''Demo2024.twinproj''
  
-{{:gb:fb:pasted:20240410-015035.png}} +===== Customize the Addin Name and Description ===== 
- +Next, let's customize the friendly name and description of our addin.  This is the info that appears in the VBA Add-in Manager dialog box
-Save as: ''M:\Repos\NLS\DevCon2024\DevCon2024.twinproj'' (in repository folder) +  - Go to **dllRegistration.twin** > **DllRegisterServer** 
- +  - In the "FriendlyName" linereplace //AddinProjectName// with ''"DevCon 2024 Demo"'' 
-Ignore ''*.twinproj'' files in repository: +  - In the "Description" line, replace //AddinProjectName// with ''"Create strongly-typed collection class from an existing VBA class object."''
- +
-<file text .hgignore> +
-syntax: glob +
-*.twinproj +
-</file> +
- +
-===== Set Export Path for Version Control ===== +
- +
-  - Ensure a clean repository with initial commit of .hgignore +
-  - **Project** > **Project Settings...** +
-  - Search for "export" +
-  - Check box next to "[√] Project: Export Path" +
-  - Enter text: ''${SourcePath}\Source'' +
-    * //This will save the twinBASIC source files to a subfolder named "Source" in the same folder as the .twinproj file itself// +
-  - Check box next to "[√] Project: Export After Save" and set value in dropdown to **Yes** +
-  - Click [Save Changes] +
-  - **File** > **Export Project...** to force an initial export +
-  - In TortoiseHgcommit with the following message: ''initial export from twinBASIC IDE'' +
-    * The commit will include over 1,000 files; this is expected +
-    * Most of the committed files come from referenced packages; that's ok +
-    * [[nls>access-version-control-my-philosophy|Remember]], "Anything that can lead to a bug in our software belongs in version control." +
- +
-===== Test Build From Source in Empty Folder ===== +
- +
-  - Create a new folder: ''%tmp%\DevConClone\'' +
-  - Clone the repository into this folder:  ''<nowiki>hg clone --verbose ssh://opal//home/gb/repos/devcon2024/ "C:\Users\Mike\AppData\Local\Temp\DevConClone"</nowiki>'' +
-  - Open new instance of twinBASIC +
-  In the _| New |_ tab, click [Import from folder...] then [Open] +
-  - Enter folder name: ''%tmp%\DevConClone\Source'' then [OK] +
-  - **File** > **Save Project As...** > ''%tmp%\DevConClone\DevCon2024.twinproj'' > [Save] +
-  - Make any small change to a project file+
   - Save the project   - Save the project
-  - Commit the change and push to Opalstack +  - Build the project 
- +  - Launch ''M:\Repos\NLS\DevCon2024\DevCon2024.accdb'' 
-   +  - Switch to VBA: <key>Ctrl</key> + <key>G</key
-===== Test Build From Source for an Existing Project ===== +  - Dock the add-in window 
- +  - Go to "Add-Ins" "Toggle myToolWindow Visibility" 
-The twinBASIC IDE appears to currently lack a "Build from Source" method that will overwrite the current .twinproj file with the contents of the "Project: Export Path" setting.  As a result, we must use this multi-step workaround: +  - Go to "Add-Ins" > "Add-in Manager" 
- +    * Point out the "DevCon 2024 Demo" item with description below 
-  - In the original repository (''M:\Repos\NLS\DevCon2024''), pull changes from Opalstack +  Close "Add-In Managerwindow 
-  - Open a new twinBASIC instance OR go to **File** **New Project...** +
-  - In the _| New |_ tab, click [Import from folder...] then [Open] +
-  For folder, enter ''M:\Repos\NLS\DevCon2024\Source'' then click [OK] +
-  - Go to **File** **Save As...** +
-  - Save project as ''M:\Repos\NLS\DevCon2024\DevCon2024.twinproj'' +
-  - Click [Yes] when asked to replace the existing file +
-  Confirm that the project successfully built from source: +
-    - Go to **File** > **Export Project...** to force a full export of the source files +
-    Verify that new "Last Modifieddates have been created in ''M:\Repos\NLS\DevCon2024\Source\'' +
-    - Verify that there are no pending changes in the repository +
  
 ===== Create the Tool Window Controls ===== ===== Create the Tool Window Controls =====
 +Next, we're going to customize the controls that appear on the tool window.  I'll explain what these controls will be used for in a minute.  For now, all you need to know is that we are adding two text boxes, a command button, and a label to hold a version number.
  
   - Open myToolWindow.tbcontrol   - Open myToolWindow.tbcontrol
   - Select all controls and delete them   - Select all controls and delete them
 +  - Click DIAGNOSTICS error to go to myToolWindow.twin and **delete all dead code**
   - Select form and set the following properties:   - Select form and set the following properties:
     * Height: 1700     * Height: 1700
Line 95: Line 75:
     * Top: 1050     * Top: 1050
     * Width: 2250        * Width: 2250   
 +  - Create a version label
 +    * Caption: Version {hhmm}  
  
 ===== Edit the Code in myToolWindow.twin ===== ===== Edit the Code in myToolWindow.twin =====
Line 108: Line 90:
 </code> </code>
  
-===== Build and Test the Addin on Same Machine ===== +===== Test the Updated Addin ===== 
-The following instructions assume a machine with 32-bit Office (e.g., mjw20):+ 
 +  - Make sure Access is closed then **Build** the tB project 
 +  - Reopen Access and switch to VBA 
 +  - Enter sample text ''oVehicle'' for object class name and ''collVehicles'' for collection class name then click [Create Collection Class] 
 +  
 +===== Strongly-Typed Collection Class ===== 
 +Now, let's talk about what this add-in will actually, you know, //do//. 
 + 
 +The purpose of the add-in is to encapsulate the ''BuildStronglyTypedCollection()'' function as described here: [[https://nolongerset.com/strongly-typed-collection-classes-the-easy-way/|Strongly-Typed Collections: The Easy Way]] 
 + 
 +I put a link to this article in the Resources page for today's presentation If you've never heard of strongly-typed collection classesI recommend you read up on them later. 
 + 
 +For our purposes, the important thing to know about them is that you CANNOT build them in the VBA editor.  They require setting a couple of hidden code attributes that only appear when you export the code module to a text file. 
 + 
 +As you can imagine, manually jumping through those hoops is inefficient and error-prone.  The existing code I wrote in VBA does automate the process, but it requires importing several additional dependencies.  Our VBE add-in will be a direct replacement for the ''BuildStronglyTypedCollection()'' function. 
 + 
 +===== Copy the VBA Code Into twinBASIC =====
  
-  - Ensure "**win32**" is selected in dropdown +  - Create a new module named MyModule.twin 
-  - **File** > **Build** +  - 
-    * Creates and registers this file: ''M:\Repos\NLS\DevCon2024\Build\DevCon2024_win32.dll'' +
-    * As part of registration, the following registry key and values are created: +
-      * ''HKEY_CURRENT_USER\SOFTWARE\Microsoft\VBA\VBE\6.0\Addins\DevCon2024.myAddIn\'' +
-        * Description: "DevCon2024" +
-        * FriendlyName: "DevCon2024" +
-        * LoadBehavior: 3  ([[https://learn.microsoft.com/en-us/visualstudio/vsto/registry-entries-for-vsto-add-ins?view=vs-2022#LoadBehavior|3 => Loaded/Load at startup]]) +
-      * ''HKEY_CLASSES_ROOT\DevCon2024.myAddIn\CLSID'' +
-        * (Default): ''{9B80DA6E-8B20-4D53-AE54-430ACFAE987B}''  //(this matches the ''[ClassID()]'' attribute value above the myAddIn class in myAddIn.twin)//\\ {{:gb:fb:pasted:20240410-034733.png}} +
-      * ''HKEY_CLASSES_ROOT\DevCon2024.myToolWindow\CLSID'' +
-        * (Default): ''{D531346A-90B8-470D-AA33-FB009F19CEFD}''  //(this matches the ''[ClassID()]'' attribute value above the myToolWindow class in myToolWindow.twin)//\\ {{:gb:fb:pasted:20240410-034605.png}} +
-      * ''HKEY_CLASSES_ROOT\CLSID\{9B80DA6E-8B20-4D53-AE54-430ACFAE987B}'' +
-        * (Default): ''myAddIn'' +
-        * ''\InProcServer32'' +
-          * (Default): ''M:\Repos\NLS\DevCon2024\Build\DevCon2024_win64.dll''  //(<wrap important>NOTE</wrap>: The presence of win64.dll here is likely a result of running the win64 build as shown in the next section)// +
-          * ThreadingModel: Both +
-        * ''\ProgID'' +
-          * (Default): ''DevCon2024.myAddIn''\\ {{:gb:fb:pasted:20240410-035346.png}} +
-    * DEBUG CONSOLE should show this:  +
-      * [LINKER] SUCCESS created output file 'M:\Repos\NLS\DevCon2024\Build\DevCon2024_win32.dll' +
-      * [LINKER]    -> Open Folder //(NOTE: this is a clickable link)// +
-      * [REGISTER] type-library registration completed. DllRegisterServer() returned OK +
-  - Open Excel or Access +
-  - Press [Alt] + [F11] to go to VBA IDE +
-  - Tool window will likely be floating; click and drag to dock it somewhere:\\ {{:gb:fb:pasted:20240410-032600.png}} +
-  - Enter ''Obj Name'' in the first text box, ''Coll Name'' in the second text box, then click [Create Collection Class]\\ {{:gb:fb:pasted:20240410-032714.png}}+
  
 ===== Build and Test the Addin on a Different Machine and Bitness ===== ===== Build and Test the Addin on a Different Machine and Bitness =====
  • 12114/demo.1713153243.txt.gz
  • Last modified: 2024/04/15 03:54 UTC
  • by mwolfe