Microsoft Forms 20 Object Library Vb6 -

Unlocking the Microsoft Forms 2.0 Object Library in VB6 If you are maintaining legacy Visual Basic 6 (VB6) applications or writing VBA macros, you have likely encountered the Microsoft Forms 2.0 Object Library (FM20.DLL). While it is primarily designed for Office UserForms, it offers a suite of versatile controls and features that can be highly useful in specialized scenarios. Key Benefits and Features

The Forms 2.0 Library provides a different set of tools compared to the standard VB6 intrinsic controls.

Enhanced Control Set: Access a variety of specialized UI elements like MultiPage, TabStrip, SpinButton, and Image controls.

Clipboard Interaction: The MSForms.DataObject is a powerful tool for sophisticated clipboard handling beyond simple text, allowing you to manage data formats more precisely.

Rich Collections: The library organizes elements into logical structures like the Controls, Pages, and Tabs collections, making it easier to programmatically iterate through complex UI layouts.

Bidirectional Support: Controls can exhibit right-to-left characteristics, which is essential for developing localized applications for certain languages. How to Add the Library to Your Project

To use these features, you must explicitly reference the library in your development environment: Open your VB6 or VBA project. Go to ToolsReferences.

Locate and check the box for Microsoft Forms 2.0 Object Library.

If it is not listed, use the Browse button to find FM20.DLL in your system folder (typically found in System32 or SysWOW64). Crucial Redistribution and Licensing Warnings

Before you start building, there are critical legal and technical "gotchas" to keep in mind: Collections, controls, and objects (Microsoft Forms)

Microsoft Forms 2.0 Object Library ) is a legacy component primarily used in VBA but occasionally referenced in Visual Basic 6.0 (VB6) to access enhanced UI features like Unicode support multi-column list boxes Spiceworks Community Core Features of the Library

While designed for VBA UserForms, it provides several advantages over standard VB6 controls: Unicode Compatibility

: Unlike standard VB6 controls, which are mostly ANSI-based, Forms 2.0 controls can display Unicode characters, making them useful for internationalization. Multi-Column Controls : It includes microsoft forms 20 object library vb6

controls that natively support multiple columns without complex API calls. Right-to-Left (RTL) Support : Controls exhibit bidirectional characteristics when the RightToLeft

property is enabled, aiding in localization for RTL languages. Advanced UI Elements : Access to controls like the objects, as well as a specialized DataObject for handling clipboard operations. How to Add the Library in VB6 Open your VB6 project. Navigate to Project > References Microsoft Forms 2.0 Object Library in the list and check the box. If not listed and navigate to C:\Windows\System32\FM20.DLL on 64-bit systems). Google Groups Critical Limitations & Risks

Developers should be cautious when using this library in compiled VB6 applications:

Add object libraries to your Visual Basic project - Microsoft Support

Using the Microsoft Forms 2.0 Object Library in VB6 Visual Basic 6.0 remains a staple for legacy enterprise applications. One of its most powerful features is the ability to integrate the Microsoft Forms 2.0 Object Library (FM20.DLL). This library allows developers to use modern-looking, versatile controls originally designed for Microsoft Office VBA. Why Use the FM20 Library?

The standard VB6 toolbox is functional but visually dated. The Microsoft Forms 2.0 library offers several advantages:

Unicode Support: Unlike standard VB6 controls, FM20 controls handle Unicode strings.

Modern Aesthetics: Controls feature smoother borders and better transparency handling.

Enhanced Functionality: The Combo Box and List Box in this library support multiple columns out of the box.

Consistency: It ensures your VB6 application UI matches the look of Office 97-2003 macros. How to Reference the Library

To use these controls, you must manually add the reference to your project: Open your VB6 Project. Go to Project > Components (Ctrl+T). Scroll down to Microsoft Forms 2.0 Object Library. Check the box and click Apply.

New icons for Buttons, TextBoxes, and Combo Boxes will appear in your Toolbox. Key Controls and Features 1. Multi-Column ListBoxes Unlocking the Microsoft Forms 2

The standard VB6 ListBox is limited to a single column of data. The FM20 version allows you to set the ColumnCount property. You can populate it using the List property array, making it ideal for displaying database records without a complex grid control. 2. Advanced TextBox Properties

The FM20 TextBox supports the EnterFieldBehavior property, which determines if text is automatically selected when the user tabs into the field. It also provides better control over scrollbars and word-wrapping. 3. The Image Control

While VB6 has an Image control, the FM20 version handles transparency and various image formats more gracefully within the Form container. Important Deployment Warnings

While powerful, the Microsoft Forms 2.0 Object Library was not designed for standalone redistribution. You must consider these factors before deploying your app:

Licensing: The FM20.DLL is not a "redistributable" file. It is typically installed by Microsoft Office. If the end-user doesn't have Office installed, your application may fail to load the controls.

The "Legal" Workaround: To ensure the DLL is present on machines without Office, users can install the Microsoft ActiveX Control Pad, which includes a licensed version of the library.

Windowless Nature: Many FM20 controls are "windowless," meaning they don't have a unique hWnd. This makes them incompatible with certain Windows API calls that require a window handle. Best Practices for Stability

Avoid Mixing Libraries: Use either standard VB6 controls or FM20 controls for a specific form. Mixing them can lead to "z-order" issues where controls overlap incorrectly.

Error Trapping: Always include robust error handling during the Form_Load event to catch missing DLL dependencies.

Use for Unicode: If your app needs to display non-Latin characters (like Cyrillic or Kanji), FM20 is often the easiest path in VB6. If you'd like, I can help you: Write a code snippet for a multi-column ListBox Debug "Object library not registered" errors Find Unicode-compatible alternatives to FM20

Common Issues

"Class not registered" error:

Controls not appearing in Toolbox:

Events not firing:

Creating Controls at Runtime

Dim fm As MSForms.UserForm
Dim txtBox As MSForms.TextBox
Dim btn As MSForms.CommandButton

' Create UserForm Set fm = New MSForms.UserForm fm.Caption = "Dynamic Form" fm.Width = 300 fm.Height = 200

' Add TextBox Set txtBox = fm.Controls.Add("Forms.TextBox.1") txtBox.Name = "txtInput" txtBox.Width = 150 txtBox.Left = 20 txtBox.Top = 20

' Add CommandButton Set btn = fm.Controls.Add("Forms.CommandButton.1") btn.Caption = "Click Me" btn.Width = 80 btn.Left = 20 btn.Top = 60

' Show form fm.Show

Method 1: Adding via Components (for Toolbox Controls)

  1. Open your VB6 project.
  2. Go to Project → Components (or press Ctrl+T).
  3. In the dialog, scroll down until you find "Microsoft Forms 2.0 Object Library".
  4. Check the box next to it and click Apply or OK.
  5. You will now see new controls in your Toolbox, including:
    • MultiPage
    • TabStrip
    • Image
    • SpinButton
    • ScrollBar

Key Components

When you add a reference to Microsoft Forms 2.0 Object Library in VB6 (via Project → References), you gain access to several powerful objects and controls, including:

Important Notes

Bridging the Gap: Using the Microsoft Forms 2.0 Object Library in VB6

If you’ve spent any time in the VB6 ecosystem, you know that the built-in controls (the intrinsic ones like TextBox, CommandButton, and Label) are reliable, but... basic. They lack modern styling, have limited event support, and let’s be honest—they look like Windows 98.

Enter the Microsoft Forms 2.0 Object Library (FM20.dll).

While originally designed for Microsoft Office (think VBA UserForms), this library is fully accessible from VB6. It offers a treasure trove of controls that are far more advanced than the standard VB6 toolbox.

In this post, we’ll explore what the library offers, how to reference it, and why you might (or might not) want to use it in your legacy projects.

Best Practices When Using MSForms 2.0 in VB6

  1. Always check for Office dependencies – Document that your app requires MS Office (or at least FM20.dll) to be present.
  2. Use early binding – Declare objects as MSForms.TextBox rather than Object for better performance and IntelliSense.
  3. Avoid mixing fonts – Use standard fonts like MS Sans Serif or Segoe UI to prevent layout shifts.
  4. Test on clean machines – Do not assume the library exists just because it works on your dev machine.

Why Use the Forms 2.0 Library in VB6?

You might wonder: "Why should I use FM20 controls when VB6 has its own native controls (Textbox, CommandButton, ListBox, etc.)?" The answer lies in features: Register fm20

  1. Multi-Column ListBox/ComboBox: The native VB6 ListBox is single-column. Forms 2.0 ListBox supports multiple columns, bound column selection, and column widths.
  2. Better Graphics Support: FM20 controls support Picture properties with transparent backgrounds, mouse icons, and alignment options.
  3. Uniform Object Model: All FM20 controls share common properties: BackColor, ForeColor, Font, Picture, MousePointer, ControlTipText, etc.
  4. Advanced Events: Events like BeforeDragOver, BeforeDropOrPaste, Scroll, Zoom (for Image control).
  5. Modern UI Feel (for its era): The library supports hot tracking, flat styles, and 3D effects.