# SftButton/OCX 4.0 — Full Documentation > SftButton/OCX is an ActiveX button control for the Windows™ operating system, offering many enhancements not found in the standard Windows button control. Online documentation: https://softelvdm.com/Documentation/SftButton%20OCX%204%200 Complete API reference (separate file): https://softelvdm.com/Vault/Softelvdm.com/llms/SftButton-OCX-4.0-reference.txt ## SftButton/OCX 4.0 Product Documentation *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/1_product_description* SftButton/OCX is an ActiveX button control for the Windows™ operating system, offering many enhancements not found in the standard Windows button control. ### Button Control SftButton/OCX offers many unique features, which can be used to enhance any application requiring button controls. - Easy to use ActiveX button control - Optional [drop down button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dropdown), great for popup menus - Up to two images in each button control (bitmaps, [GDI+](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus) images, icons, animations and Windows metafiles) - Single and multiline text - Customizable Click event - Supports standard [button style](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_button) and [toggle button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toggle) style - Application defined colors even for border lines - Support for ActiveX (OLE) control containers such as Visual Studio .NET, Visual Basic, Visual C++, Access, and many more - Small size ActiveX control requiring NO external run-time DLLs - Includes digitally signed cabinet file - Stand-alone implementation, not a sub/superclassed button control (not based on Windows Button control class) - [Default button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_default_button) handling and outlining - [OLE drag & drop](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_oledragdrop) support - Dual interfaces throughout for optimum performance - No MFC DLLs, no VB runtime or other DLLs required ### Royalties Any application that you develop can use SftButton/OCX royalty-free in run-time only mode; design-time features are not available. Each user (developer) who needs access to design-time features must license a copy of SftButton/OCX. ### Languages Supported SftButton/OCX supports all popular ActiveX (OCX) platforms, such as Visual Studio .NET, Visual Basic, Visual C++ and many more. Feature limitations may exist depending on the platform used. These are generally caused by the platform, rather than our control product, which implements the current ActiveX control standards specifications. ### Environments Supported SftButton/OCX supports Windows 10, Windows 11 and their server editions using the same set of properties, events and methods. UNICODE support is available for all platforms. ### AI / LLM Documentation The complete SftButton/OCX documentation is also published in an AI/LLM-readable format, following the [llms.txt convention](https://llmstxt.org). The index covering all Softel vdm products is at [https://softelvdm.com/llms.txt](https://softelvdm.com/llms.txt). The product installation includes an AGENTS.md file at the installation root, which points AI coding assistants at the product's online guide and API reference. The documentation is always read online, as it is updated between product releases. ## New Features *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_newfeatures* SftButton/OCX 4.0 is virtually 100% upward compatible from version 3.0 and older versions. Upgrading a project from an older version usually takes just a few minutes. For details about upgrading, please see "[Upgrading To Version 4.0](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_upgrading)". ### Product Enhancements - [Dark mode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_darkmode) support. The [DarkMode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DarkMode) property follows the Windows "Choose your mode" setting, or forces the light or dark palette. [DarkModeActive](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DarkModeActive) reports the current state and the [DarkModeChange](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DarkModeChange) event is raised when it changes. - [Windows High Contrast](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_highcontrast) support, enabled by default. When the user's contrast theme is active the control renders with the system palette and ignores application-chosen colors, as Microsoft's [accessibility](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_accessibility) guidelines require. See the [HighContrastMode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_HighContrastMode) and [HighContrastActive](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_HighContrastActive) properties and the [HighContrastChange](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_HighContrastChange) event. - Accessibility - built-in Windows UI Automation support, so Narrator, NVDA, JAWS and other assistive technologies can read and operate the control. No opt-in and no code change is required. - [Per-Monitor DPI](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dpi) awareness. The control re-renders when its window moves to a monitor with a different DPI. The [DPI](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DPI) property returns the current monitor DPI and the [DPIChanged](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DPIChanged) event reports the change. - The [ImageScaling](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_ImageScaling) property scales the images supplied to the control by the current DPI, so artwork prepared at 96 DPI keeps its physical size on a high-DPI monitor. - Support for Visual Studio 2026, 2022 and 2019, including automatic addition of the control to the Toolbox. ## Installing SftButton/OCX *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_installation* ### System Requirements SftButton/OCX 4.0 has the following system requirements: - The control supports 32-bit and 64-bit applications under Windows 10, Windows 11 and their server editions. - There are no minimum system requirements to use the control. - A 32-bit or 64-bit Windows development environment and a compiler/language, which supports ActiveX controls. - Approximately 40MB of hard disk space is required to install SftButton/OCX. ### Installing SftButton/OCX When you are ready to install SftButton/OCX: 1. Run the setup application - The download location is provided either with your license information at the time of purchase or you can download the product [demo](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_demo_application) from our web site. Both the product and demo setup applications are identical and can be used interchangeably. ![Installation](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/installation.png) 2. Follow the instructions on the installation dialogs. Please note that the single developer version of SftTree/OCX can only be installed by one user on one system. Multiple developer licenses and site licenses are available. Contact [Softel vdm, Inc.](https://softelvdm.com/about) for more information. 3. During the installation, you will be prompted to register the product using the License Manager application. Without proper registration, the product will not run. Once you are a registered user, you can take advantage of our [product support](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_contactsoftel), such as free maintenance versions, and you will receive information regarding new releases. 4. Once SftTree/OCX has been successfully installed, you will find a new program group SftButton/OCX 4.0. Entries for the SftButton/OCX Demo, sample applications, the on-line help and the release notice have been added. ## Upgrading To Version 4.0 *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_upgrading* ### Converting an Existing Application > The conversion is not automatic, but takes just a few minutes for a project. Only a minimal conversion is required when upgrading from SftButton/OCX 3.0 to SftButton/OCX 4.0. SftButton/OCX 4.0 is virtually 100% source compatible to older releases of SftButton/OCX. Your application(s) must be recompiled to use SftButton/OCX 4.0. **SftButton/OCX 4.0** and older versions of SftButton/OCX can coexist on the same system and can be used in the same application. > Make sure to back up your current projects, before converting your projects. Please read the conversion process specific to your language carefully *BEFORE* converting your project. After converting, once the control saves updated property settings, you will not be able to return to SftButton/OCX 3.0. Visual Basic .NET (Managed Languages) Visual C++ (Unmanaged C/C++) Other Development Tools #### Visual Basic After [installing SftButton/OCX](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_installation) 4.0, all your projects will continue to use SftButton/OCX 3.0 until you make the following change in each project's main VBP (Visual Basic Project) file. Before opening the project file, make sure to close the project in Visual Basic, then edit the VBP file using a text editor and make the following changes: **Existing Project File (VPB File):** ``` Type=Exe Form=Form1.frm Reference=*\G{{00020430-0000-0000-C000-000000000046}}#2.0#0#G:\WINNT\System32\stdole2.tlb#OLE Automation Object={{A65EEE90-0739-4116-8236-6DCAD56452B6}}#3.0#0; SftButton_IX86_U_30.ocx IconForm="Form1" Startup="Form1" ExeName32="yourexe.exe" Command32="" Name="yourproject" ``` The line describing **SftButton/OCX 3.0** (above, using a bold font) should be replaced with the following line: ``` Object={{FDF97785-BE20-410C-9FBA-882812DAFF0F}}#4.0#0; SftButton_IX86_U_40.ocx ``` You can copy this line directly from this help file or copy it from the file "Upgrade.txt" which you can find in the SftButton/OCX product directory. The line must be copied as-is, without any modifications. **Existing Forms And Modules (FRM, BAS Files):** All forms and modules must be edited using a text editor. The following changes can easily be accomplished by a global edit and replace operation: - Edit all occurrences of **SftButtonLib30** and replace them with **[SftButtonLib40](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/i_object_hierarchy)** Once the VBP and FRM file have been saved, you can open the project in Visual Basic. Make sure to review each form (in design mode) and save it to complete the upgrade. The controls will save updated property settings, so you will **not** be able to return to SftButton/OCX 3.0. Once all forms have been saved, the project is using SftButton/OCX 4.0. #### .NET (Managed Languages) While most other languages offer a fairly easy conversion, .NET and its languages require a bit more effort, but in most cases is limited to the steps documented below. **Existing Forms (FRM Files):** Updating the forms to use SftButton/OCX 4.0 is quite straightforward: - A reference to SftButton/OCX 4.0 needs to be added to the project. This is easily accomplished by adding a SftButton/OCX 4.0 control to any form of your project. It is located in the toolbox group *Softel vdm, Inc. *For information about this, please see "[Using SftButton/OCX with .NET](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_dotnet)". As soon as this new control is added to your form, the references are added to your project. The Solution Explorer window now shows two new references to AxSftButtonLib40 and SftButtonLib40. Once these references are added, the new control can be deleted from your form. The references remain. - If you are upgrading from a version prior to 3.0 also perform the following step: - Add the SftHelperComponent component to your form. It is located in the toolbox group *Softel vdm, Inc. *For information about this, please see "Using SftButton/OCX with .NET". The SftHelperComponent component is required for [GDI+](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus)/.NET Image object support using the NETImageObject property. It also eliminates the need for the OLEConvert.cs or OLEConvert.vb source files that were used in earlier releases. - Close all forms. - Open each form, one at a time, using the *View Code *menu entry in the Solution Explorer window. The popup menu is accessed by right-clicking on a form name. If you accidentally open a form in design mode, close it without saving, as your current button control settings for this form are most likely lost. - Edit all occurrences of **SftButtonLib30** and replace them with **SftButtonLib40** - If you are upgrading from a version prior to 3.0 also perform the following steps: - **C#:** Edit all occurrences of **using OLEConvert;** and replace them with **using Softelvdm.OLEConvert;** - **VB:** Edit all occurrences of **Imports* ****projectname***.OLEConvert** and replace them with **Imports Softelvdm.OLEConvert** - The existing references to SftButton/OCX 3.0 (or older) can now be removed. If the Solution Explorer window shows references to AxSftButtonLib30 and SftButtonLib30, these can be removed. - If your project includes the source file OLEConvert.cs (C#) or OLEConvert.vb (VB), remove it now. It is no longer needed. The forms can now be opened and the project uses SftButton/OCX 4.0 exclusively. You will **not** be able to return to SftButton/OCX 3.0. #### Visual C++ (Unmanaged C/C++) ##### Resource Files After installing SftButton/OCX 4.0, all your projects will continue to use SftButton/OCX 3.0 until you make the following change in each dialog resource that defines a SftButton/OCX control. Before opening the resource script (RC file), make sure to close the project in Visual C++, then edit the RC file using a text editor and make the following changes: ``` IDD_MFC_DIALOG DIALOGEX 0, 0, 320, 200 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "MFC" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,260,7,50,14 PUSHBUTTON "Cancel",IDCANCEL,260,23,50,14 CONTROL "",IDC_SFTBTN1,"{A65EEE94-0739-4116-8236-6DCAD56452B6}", WS_TABSTOP,135,99,51,18 END ``` The contents of the line describing SftButton/OCX 3.0 (above, using a bold font) should be replaced with the following: ``` CONTROL "",IDC_SFTBTN1,"{BAFC6953-85FA-4915-859A-3AF4ED991437}", ``` Only change the ClassID (i.e., {A65EEE94-0739-4116-8236-6DCAD56452B6}), do not change the rest of the line. You can copy this information directly from this help file or copy it from the file "Upgrade.txt" which you can find in the SftButton/OCX product directory. The ClassID must be copied as-is, without any modifications. Once the RC file has been saved, you can open the project in Visual C++ and the project is now using SftButton/OCX 4.0. The controls will save updated property settings, so you will **not** be able to return to SftButton/OCX 3.0. Make sure to change ALL occurrences of SftButton/OCX to version 4.0, otherwise you will not be able to open the resource script (RC file). ##### #import Statements The #import statement used with SftButton/OCX 3.0 must be replaced with an #import statement for the new version: Version 3.0: ``` #pragma warning(disable : 4192) // automatically excluding 'Ixxx' while importing type library 'stdole2.tlb' // For information about the following construct, please see Microsoft's // KnowledgeBase entry Q224610 #import rename_namespace("SftButtonNameSpace") exclude("OLE_HANDLE", \ "OLE_COLOR", "IFontDisp", "IPictureDisp", "FONTSIZE") #import rename_namespace("SftButtonNameSpace") rename("LoadImage", "LoadImageSftButton") #if _MSC_VER >= 1400 // need at least Visual Studio 2005 # pragma comment(lib, "comsuppw.lib") // avoid link error in VS2005 #endif #pragma warning(default : 4192) using namespace SftButtonNameSpace; ``` New for SftButton/OCX 4.0: ``` #pragma warning(disable : 4192) // automatically excluding 'Ixxx' while importing type library 'stdole2.tlb' // For information about the following construct, please see Microsoft's // KnowledgeBase entry Q224610 #import rename_namespace("SftButtonNameSpace") exclude("OLE_HANDLE", \ "OLE_COLOR", "IFontDisp", "IPictureDisp", "FONTSIZE") #import rename_namespace("SftButtonNameSpace") rename("LoadImage", "LoadImageSftButton") #if _MSC_VER >= 1400 // need at least Visual Studio 2005 # pragma comment(lib, "comsuppw.lib") // avoid link error in VS2005 #endif #pragma warning(default : 4192) using namespace SftButtonNameSpace; ``` #### Other Development Tools Most development tools allow access to the ClassID used for controls on a form or dialog. Sometimes this may be accomplished by using a text editor and editing a configuration file, or possibly the development tool allows direct modification of the ClassID. Generally, the ClassID used for the prior release {A65EEE94-0739-4116-8236-6DCAD56452B6} must be replaced with the new ClassID {BAFC6953-85FA-4915-859A-3AF4ED991437}. Once this step is completed, opening the project is sufficient to allow SftButton/OCX to convert the stored property settings. For specific instructions or help, please see your development tool's documentation. ## Button *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_button* SftButton/OCX provides basic button control features and extends these by offering a multitude of configuration options, events and methods. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/theme1.gif) The [button label](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_label) of each SftButton/OCX control offers up to two picture components and a single or multiple lines of text. In addition, a button can display an optional [drop down button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dropdown). This drop down button can be used to access dialogs, popup menus, etc. and is similar in function to a combo box drop down button. The [AllowFocus](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_AllowFocus) property can be used to define whether the button control receives the input focus when the user clicks on it. The button generates the [Click](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_Click) event when the button is clicked (see [Keyboard & Mouse Interface](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_keyboard)). In addition, the button (and the drop down button) can also act as a [toggle button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toggle). ## DropDown Button *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dropdown* SftButton/OCX offers an optional drop down button. This drop down button can be used to access dialogs, popup menus, etc. and is similar in function to a combo box drop down button. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/button_1.gif) The [ShowDropDown](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_ShowDropDown) property is used to enable the drop down button. The drop down button generates the [DropDownClick](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DropDownClick) event when it is clicked (see [Keyboard & Mouse Interface](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_keyboard)). In addition, the drop down button (and the button portion) can also act as a [toggle button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toggle). ## Button Label *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_label* A button displays a button label, which consists of an optional text component and two optional picture components. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/button_label_sampledialog.gif) ### Text Component The [Text](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Text) property defines the control's caption. One single line of text or multiple lines are possible. The text portion can also define an [accelerator key](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_accel) using an embedded & character. If the text component is clipped horizontally, the text is truncated and the characters "..." are displayed at the end of the truncated text. If the text component is clipped vertically, no special processing occurs. ### Picture Components The properties [Image1](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1) and [Image2](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image2) define optional picture components. Each can define a bitmap, icon, [GDI+](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus) image, Windows metafile. Icons, animations and Windows metafiles define transparent images and will be displayed properly within the button. The [Image1Hover](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1Hover) and [Image2Hover](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image2Hover) properties are used if the mouse cursor is located on the control or picture component, [Image1Pressed](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1Pressed) and [Image2Pressed](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image2Pressed) are used if the button is pressed or [Image1Disabled](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1Disabled) and [Image2Disabled](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image2Disabled) are used if the control is disabled (see Enabled property). Otherwise, the Image1 and Image2 properties are used to determine the displayed graphics. ### Properties The button label of a button is defined using the following methods and properties: | Property/Method | Description | | --- | --- | | [AVIPlay](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_AVIPlay) | Defines the animation used as a button picture component. | | [AVIPlayResource](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_AVIPlayResource) | Defines the animation used as a button picture component. | | Image1 | Defines the first graphic. | | [Image1AlignHorz](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1AlignHorz) | Defines the horizontal alignment of the first graphic. | | [Image1AlignVert](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1AlignVert) | Defines the vertical alignment of the first graphic. | | Image1Disabled | Defines the first graphic when the button is disabled. | | Image1Hover | Defines the first graphic when the mouse cursor is located on the control. | | Image1Pressed | Defines the first graphic when the button is pressed. | | Image2 | Defines the second graphic. | | [Image2AlignHorz](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image2AlignHorz) | Defines the horizontal alignment of the second graphic. | | [Image2AlignVert](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image2AlignVert) | Defines the vertical alignment of the second graphic. | | Image2Disabled | Defines the second graphic when the button is disabled. | | Image2Hover | Defines the second graphic when the mouse cursor is located on the control. | | Text | Defines the control's caption. | | [TextAlignHorz](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_TextAlignHorz) | Defines the horizontal alignment of the text. | | [TextAlignVert](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_TextAlignVert) | Defines the vertical alignment of the text. | ### Orientation Two basic button label styles are available, defining the basic orientation of the text and picture components (Orientation property): | | | | --- | --- | | ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/orient_horz.gif) | Horizontal Orientation | | ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/orient_vert.gif) | Vertical Orientation | Once the orientation is chosen, the relative position of each component (Image1, Text, Image2) is defined using the alignment properties Image1AlignHorz/Image1AlignVert, TextAlignHorz/TextAlignVert and Image2AlignHorz/Image2AlignVert. #### Horizontal Orientation The horizontally available empty space between the components Image1, Text, Image2 is distributed based on each component's alignment property setting. First, Image1 is aligned horizontally using the Image1AlignHorz property, then Text is aligned within the new remaining space using the TextAlignHorz property, followed by Image2 which is aligned within the remaining space using the Image2AlignHorz property. The vertical alignment is defined using the properties Image1AlignVert, TextAlignVert and Image2AlignVert. If a component is empty or not defined, its alignment settings have no effect. #### Vertical Orientation The vertically available empty space between the components Image1, Text, Image2 is distributed based on each component's alignment property setting. First, Image1 is aligned vertically using the Image1AlignVert property, then Text is aligned within the new remaining space using the TextAlignVert property, followed by Image2 which is aligned within the remaining space using the Image2AlignVert property. The horizontal alignment is defined using the properties Image1AlignHorz, TextAlignHorz and Image2AlignHorz. If a component is empty or not defined, its alignment settings have no effect. ## Toggle Button *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toggle* In addition to simple button functionality, a SftButton/OCX control can also operate as a toggle button, i.e., a button that can not only be clicked, but provides an on and an off position. Each mouse click will alternate between the on (pressed) and off (released) positions. The [Toggle](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Toggle) property is used to define toggle button behavior. The [drop down button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dropdown) can also act as a toggle button. This is defined using the [DropDownToggle](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DropDownToggle) property. ## Using Themes *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_themes* Windows themes can be selected by the user using the Windows settings. If a theme is selected, the display of user interface controls, such as SftButton/OCX, adapts to the current display theme. Themes can provide various display styles for the same control. With themes active, Windows renders (paints) the control: | | | | --- | --- | | ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/theme2.gif) | ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/theme1.gif) | | Without Themes | With Themes | By using the [UseThemes](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_UseThemes) property, SftButton/OCX adapts to the current theme used. If set to 0 (No), themes are not honored and the control is rendered using the built-in style. SftButton/OCX makes it easy to use the same application across all supported platforms. If Windows themes are not available, the control will simply use its built-in display style, otherwise it will fully exploit Windows themes. To prepare an application for proper themes support, the control should be designed and tested on a supported Windows platform. It should be viewed both with and without themes to make sure that the defined control is visually satisfactory in both cases. Controls designed for use on a Windows version with themes will work identically on all other platforms, even when themes support is not available. > Keep in mind that numerous control definitions, particularly relating to colors, have no effect when themes are active. You can find out if a specific control setting has any effect with themes active by consulting the detail information in this documentation. ## Default Button *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_default_button* SftButton/OCX can be used as a default button as it implements the necessary functionality. Default button handling also depends on the containing application (i.e., your development tool/language). Certain environments may not properly support a default button (see OLEMISC, OLEMISC_ACTSLIKEBUTTON). Particularly property sheets do not always properly support default buttons. If a button is defined as the default button, the button is painted using a darker outline. If the user presses the Enter key on a form with a default button, the default button's [Click](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_Click) event fires. ### .NET ActiveX controls are not supported as default buttons. ### Visual Basic Visual Basic offers full default button support. The Default property is added to SftButton/OCX by Visual Basic. It defines whether the button is a default button. For more information, please see the Visual Basic documentation. ### Visual C++/MFC A SftButton/OCX button control can be defined as the default button using the CDialog::SetDefID function. This function is called at run-time, usually in the OnInitDialog or OnCreate member function of the parent dialog or window. ### Delphi, C++Builder ActiveX controls are not supported as default buttons. ### Other A SftButton/OCX button control can be defined as the default button using the Windows dialog manager's DM_SETDEFID message. This message is sent to the parent dialog, specifying the ID of the default button, usually while handling the WM_INITDIALOG or WM_CREATE message of the parent dialog or window. ## Accelerator Keys *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_accel* The [Text](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Text) property defines the control's caption. The caption can include an accelerator key. By using the & character in the Text property, the following character becomes an accelerator key. If the user types Alt plus the defined accelerator key, the control receives the input focus and the [Click](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_Click) event occurs. For example, if the Text property is set to "&Help", the displayed caption will read "Help", i.e., the H is underlined. If the user types Alt+h, the Click event occurs. To display an & character use "&&". If the [AllowFocus](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_AllowFocus) property is set to False, the control does not support accelerator keys. The & character is displayed as-is. ## Keyboard & Mouse Interface *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_keyboard* ### Keyboard Interface If the button control has the input focus, pressing the space bar will fire the [Click](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_Click) event. If the [drop down button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dropdown) is available (see [ShowDropDown](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_ShowDropDown)) and the button control has the input focus, pressing the Alt key and the down arrow key at the same time will fire the [DropDownClick](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DropDownClick) event. If the user types Alt plus the defined [accelerator key](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_accel), the Click event occurs. If the button is the form's or dialog's [default button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_default_button), pressing the Return key will fire the Click event. ### Mouse Interface By clicking and releasing the left mouse button on the button (button portion), the Click event will fire. If the mouse button is double-clicked, the [DblClick](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DblClick) event occurs. The [MouseDown](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_MouseDown), [MouseUp](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_MouseUp) and [MouseDblClk](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_MouseDblClk) events can also occur, reflecting the actual mouse button status, but only the Click or DblClick events should be used to determine if a button has been pressed. By clicking and releasing the left mouse button on the drop down button, the DropDownClick event will fire. Based on the [DropDownDownClick](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DropDownDownClick) property, the event fires as the mouse button is pressed or released. If the mouse button is double-clicked, the [DropDownDblClick](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DropDownDblClick) event occurs. The MouseDown, MouseUp and MouseDblClk events can also occur, reflecting the actual mouse button status, but only the DropDownClick or DropDownDblClick events should be used to determine if a drop down button has been pressed. ## GDI+ *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus* If GDI+ is available, the button control supports additional features not otherwise available. Images defined using the Image1 and Image2 properties support PNG, TIFF, JPEG, GIF, Exif, EMF+, EMF (GDI+ images) with full alpha-blended (translucent and semi-transparent) images. GDI+ is always available on all supported Windows platforms. If GDI+ support is not available, the features are simply disabled and alternate presentation methods are used, if available. ## Bitmap Transparency *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_transparency* SftButton/OCX automatically uses bitmap transparency for all bitmaps used throughout a control. When a bitmap is displayed, the background can show through portions of the bitmap. SftButton/OCX accomplishes this by dynamically modifying a copy of the bitmap to adjust for the background color. While icons and Windows metafiles are also supported by SftButton/OCX, these file formats already define transparency, based on how the image was created. These file formats receive no special processing by SftButton/OCX. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/transparency_1.gif) The top, left pixel of each bitmap is inspected as the bitmap is painted. The color of that pixel represents the bitmap's background color. This color is replaced throughout the bitmap with the actual background color. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/transparency_2.gif) If the bitmap image includes the top, left pixel, add an extra row or column of pixels to the bitmap, so the image does not include the top, left pixel. Bitmap transparency is only used for bitmaps and is not used for icons, images in an ImageList control, Windows metafiles, [GDI+](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus) images (e.g, [NETImageObject](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftPictureObject_NETImageObject) property) or other images that can be represented by a [SftPictureObject object](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/index_SftPictureObject). > **.NET** When [using SftButton/OCX with .NET](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_dotnet), bitmap transparency is only used for bitmaps loaded using the [property pages](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog). Any bitmaps converted from a PictureBox or an Image object will not use bitmap transparency. With .NET, the PictureBox control and Image [objects](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/i_object_hierarchy) support all image formats (gif, jpeg, ico, etc.) and are also supported by SftButton/OCX. Some of these image formats already define transparency and should be used if image transparency is desired. Bitmap transparency is fully automatic (for images based on bitmaps) and cannot be turned off. Icons, animations and Windows metafiles are not affected by bitmap transparency. ## OLE Drag & Drop *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_oledragdrop* SftButton/OCX supports OLE drag & drop, based on the [OLEDragMode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_OLEDragMode) and [OLEDropMode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_OLEDropMode) settings. Events such as the [MouseDown](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_MouseDown) event can be used to determine the start of a drag & drop operation. ### OLE Drag & Drop If the OLEDragMode property is set to OLEDragSftButtonManual, OLE drag & drop mechanisms are used. This is the most powerful drag & drop method supported by SftButton/OCX. In this mode, drag & drop between controls in the same application and between different applications is supported. Using the OLEDropMode property, SftButton/OCX can be defined as a valid drop target. The [OLEDragDrop](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_OLEDragDrop) event occurs when a drop occurs on the control. The application can retrieve the data and data format using the [DataObject](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/index_DataObject).[GetData](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/DataObject_GetData) and [GetFormat](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/DataObject_GetFormat) methods. SftButton/OCX can also be used as the source of a drag & drop operation. By using the OLEDragMode property (set to OLEDragSftButtonManual), the [OLEStartDrag](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_OLEStartDrag) event occurs as soon as a drag & drop operation is about to begin (initiated by the application using the [OLEDrag](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_OLEDrag) method). The DragMode property (in Visual Basic) must be set to vbManual for OLE drag & drop. In the OLEStartDrag event, the application can define the data or data formats and drop effects that are supported for the drag & drop operation. ### Drag & Drop Controlled by the Container Application Visual Basic also supports its own drag & drop which is not based on OLE. Visual Basic's drag & drop methods only operate within the same application. The DragMode property (added to the control and documented by Visual Basic) controls this drag & drop processing. Please see the Visual Basic documentation for more information. Other container applications may provide their own drag & drop implementation. For example, Visual C++ offers the C++ classes COleDropSource and COleDropTarget, which offer considerable features to implement OLE Drag & Drop. A suitable event (such as the MouseDown event) could be used to determine when a drag & drop operation starts, but the application can then choose to use the COleDropSource and COleDropTarget classes to implement its own OLE drag & drop mechanisms. ## Dark Mode *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_darkmode* SftButton/OCX 4.0 supports dark mode. By default the button control uses the light palette. An application opts in by setting the [DarkMode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DarkMode) property to [darkSftButtonAuto](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/constants_SftButtonDarkModeConstants) so the control follows the Windows "Choose your mode" setting automatically - users who have selected Dark see a dark color palette and users who have selected Light see the traditional palette, and the control re-renders when the user flips between them. darkSftButtonOn always uses the dark palette regardless of the Windows setting. What changes in dark mode: the button face, caption text, border and edge lines, the drop-down button and its arrow, and the hover, pressed and disabled appearances all switch to dark-palette colors. Images supplied by the application are drawn unchanged - see below. The DarkMode property has three values (see SftButtonDarkModeConstants): | Value | Description | | --- | --- | | darkSftButtonAuto | Follow the Windows "Choose your mode" setting. The control re-renders when the system setting flips. | | darkSftButtonOn | Always use the dark palette, regardless of the Windows setting. Useful when the hosting application has its own Light / Dark toggle and wants the button to follow it. | | darkSftButtonOff (default) | Always use the light palette, regardless of the Windows setting. Useful when the application does not yet support dark mode end-to-end and mixing dark and light controls would look wrong. | The [DarkModeChange](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DarkModeChange) event is fired each time the active dark mode state flips (darkSftButtonAuto only) so the application can repaint its own chrome around the button control. The [DarkModeActive](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DarkModeActive) property reports the current state at any time. Caller-supplied color overrides ([BackColor](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_BackColor), [ForeColor](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_ForeColor), the gradient and hover colors, and the edge colors) are still honored in dark mode - the control does *not* override application-chosen colors. If you set explicit colors and also want dark mode, pick accent colors that read well on both a light and a dark background (mid-tone saturated values in the RGB 30-210 range tend to work in both). Images are the application's responsibility. A button whose image was drawn for a light background will still be drawn as supplied when the palette turns dark. Where that matters, supply artwork that reads on both palettes, or switch images when the DarkModeChange event reports a change. Dark mode and [Windows High Contrast](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_highcontrast) are independent settings. If the user has both enabled, high contrast takes precedence. See High Contrast. ## High Contrast *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_highcontrast* Windows High Contrast is an [accessibility](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_accessibility) setting, not a visual preference. Users who enable it have committed to a specific high-contrast color scheme for everything on screen, and Microsoft's accessibility guidelines require applications to let the user's scheme win over any application-chosen colors. SftButton/OCX 4.0 follows this rule automatically, and unlike most of the control's settings it does so without the application opting in - [HighContrastMode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_HighContrastMode) defaults to [highContrastSftButtonAuto](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/constants_SftButtonHighContrastConstants). When Windows High Contrast is active, the button control draws its face, caption, border and drop-down button using the system high-contrast colors, ignores caller-supplied color overrides so the user's contrast theme wins, and falls back to the system button and toolbar theme classes so the chrome matches the rest of the user's desktop. The HighContrastMode property has three values (see SftButtonHighContrastConstants): | Value | Description | | --- | --- | | highContrastSftButtonAuto (default) | Follow the Windows High Contrast setting. The control re-renders when the setting flips. | | highContrastSftButtonOn | Always use the system palette, regardless of the Windows High Contrast setting. Useful for testing, or for applications that want consistent high-contrast rendering for a specific button. | | highContrastSftButtonOff | Ignore the Windows High Contrast setting and render normally. Not recommended in shipping applications - it means users with accessibility needs will see rendering that does not comply with their contrast theme. Appropriate only where the application already paints its own high-contrast-aware chrome and inspects [HighContrastActive](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_HighContrastActive) itself. | The [HighContrastChange](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_HighContrastChange) event is fired each time the active state flips (highContrastSftButtonAuto only) so the application can repaint its own chrome to match. The HighContrastActive property reports the current state at any time. [Dark mode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_darkmode) and Windows High Contrast are independent. If the user has both enabled, high contrast takes precedence - the contrast theme's palette wins over the dark palette, because honoring the user's contrast theme is the stronger accessibility requirement. See Dark Mode. ## Accessibility (Screen Readers) *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_accessibility* SftButton/OCX 4.0 includes built-in Windows UI Automation (UIA) support. Users who rely on Narrator, NVDA, JAWS or any other UIA-compatible assistive technology can read and operate the control without the hosting application doing any work. There is no opt-in and no code change required. What the screen reader sees: | Element | Exposed as | | --- | --- | | Control type | **Button**. The control advertises the Invoke pattern, so an assistive technology can activate it the same way a mouse click or the space bar would. | | Name | The button's [Text](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Text) caption, with the & mnemonic marker removed. The mnemonic character itself is reported separately as the access key. | | State | Enabled or disabled, whether the control has keyboard focus, and for a [toggle button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toggle) ([Toggle](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Toggle)) whether it is currently pressed. | Event notifications are raised automatically when the button is invoked, when it gains or loses keyboard focus, and when its caption changes. The provider loads on demand the first time a UIA client queries the control, so there is no overhead for applications whose users never attach an assistive technology. Two things the application controls: - Give every button a meaningful Text caption. The caption is what the screen reader announces; a button that carries only an image has nothing to say. Where the design calls for an image-only button, set the caption anyway - it is not drawn when the [button style](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_button) shows images alone, but it is still reported to assistive technology. - Include a mnemonic in the caption (for example &Save) so keyboard users can reach the button directly. [Dark mode](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_darkmode) and [Windows High Contrast](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_highcontrast) are independent accessibility settings. SftButton/OCX honors both automatically. See Dark Mode and High Contrast. ## Per-Monitor DPI and Scaling *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dpi* SftButton/OCX 4.0 is fully Per-Monitor v2 DPI-aware. A button control hosted on a Per-Monitor v2 aware top-level window re-renders automatically when its window moves to a monitor of a different DPI or when the system DPI changes. The control owns the metrics it controls; the caller owns the images and fonts it provides. One opt-in property lets the caller hand the images over to the control as well. ### Host setup The host application must declare Per-Monitor v2 DPI awareness. This is the single most common reason high-DPI applications do not re-render correctly when moved between monitors of different DPI. Without a Per-Monitor v2 declaration, Windows keeps the process in System-aware mode: the DPI is fixed for the process lifetime, the control does not observe DPI changes, the [DPIChanged](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButtonEvents_DPIChanged) event is never fired, and high-DPI monitors render at System-DPI sizes stretched by Windows. Declare Per-Monitor v2 awareness in the host application's manifest, for example: ``` PerMonitorV2 True/PM ``` In a .NET project, this corresponds to selecting *Per Monitor V2* for the application's DPI awareness. The [DPI](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_DPI) property returns the control's current monitor DPI (96 at 100%, 120 at 125%, 144 at 150%, 192 at 200%). If the returned value never changes as the window is dragged between monitors with different scale factors, the host is not in Per-Monitor v2 mode. ### What scales automatically When the host is Per-Monitor v2 aware, the control scales the metrics it owns itself on every DPI change without any caller involvement: the border and edge widths, the focus rectangle, the drop-down button width and its arrow, and the internal spacing between the caption and the images. ### What the caller controls [ImageScaling](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_ImageScaling) decides whether the images supplied to the control also scale with DPI. It uses [SftButtonScalingConstants](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/constants_SftButtonScalingConstants): | Value | Effect | | --- | --- | | scalingSftButtonStretch (default) | Images are scaled by *current DPI / 96* using high-quality interpolation, so artwork prepared at 96 DPI keeps its physical size on a high-DPI monitor. | | scalingSftButtonAsIs | Images are drawn at their native pixel size. Appropriate when the application already supplies artwork prepared for the current scale factor. | The setting covers every image the application gives the control: the [Image1](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1) and [Image2](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image2) families and the background images, including their hover, pressed and disabled variants. ### On DPI change When the control's monitor DPI changes, the DPIChanged event is fired. The application should re-send a font sized for the new DPI (the control does not own the application's font). If ImageScaling is left at its default of scalingSftButtonStretch, no further action is needed - the control scales the existing images automatically. ## Using SftButton/OCX *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using* SftButton/OCX can be used with most development tools that support ActiveX controls. This section shows how to use the control with some of the most popular development tools. The control is automatically registered in the Windows Registry during installation of SftButton/OCX. Please see [Distributing SftButton/OCX](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_distributing) for information on how to ship the control with your application. Many development tools offer a palette or tool bar of available ActiveX controls. The control SftButton/OCX may be added to these tool bars automatically, or you may have to take additional steps to make the control available to a development tool or project. Check your development tool's documentation for detailed information on how to use ActiveX controls. - [Using SftButton/OCX with .NET](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_dotnet) - [Using SftButton/OCX with Visual Studio (Unmanaged C/C++)](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_vc7) - [Using SftButton/OCX with Visual Basic 6](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_vb6) - [Using SftButton/OCX with Other Development Tools](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_other) Once the SftButton/OCX control is available, it can be added to forms, dialogs or windows. By right clicking on the control in design mode, most development tools will display a popup menu which allows access to the [Property Dialogs](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog) provided by SftButton/OCX. The Property Dialogs are used to define all design-time properties of the control. Some development tools also display their own property window. This property window normally displays only the properties of the SftButton/OCX object. Other [objects](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/i_object_hierarchy) which the control may offer are not shown. These can only be modified though the Property Dialogs. The development tool's property window may provide access to the SftButton/OCX online help using the F1 key or a similar mechanism. The Property Dialogs offered by SftButton/OCX display context sensitive help by double-clicking on the description of a property or by right-clicking on any displayed property of the Property Dialogs. ## Using SftButton/OCX with .NET *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_dotnet* Adding SftButton/OCX To The Toolbox Adding SftButton/OCX To A Project Adding The SftHelperComponent To A Project Preparing a Project Special Considerations - Picture Properties - Color Properties Object vs. Interface ### Adding SftButton/OCX To The Toolbox The controls are automatically added to the Visual Studio Toolbox in the toolbox group *"Softel vdm, Inc."*, except for Visual Studio .NET 2002 and all Visual Studio Express Editions. For these, the controls have to be added "manually" using the simple procedure outlined in "[Adding Controls To The Visual Studio Toolbox](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toolboxvs)". If you are using Visual Studio .NET 2002 or any of the Visual Studio Express Editions, please take a moment to add the controls using the simple procedure outlined in "Adding Controls To The Visual Studio Toolbox" before continuing. ### Adding SftButton/OCX To A Project The SftButton/OCX control can be added to a form, by locating the control in the toolbox group *"Softel vdm, Inc."*. It can be added to a form by clicking on the SftButton/OCX button of the toolbox, then clicking on the form or by dragging the SftButton/OCX button of the toolbox to the form. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/net/using1.gif) ### Adding The SftHelperComponent To A Project In order to be able to use .NET images, color and font properties, a small helper component must be added to each project that uses SftButton/OCX. This helper component assists in to converting OLE types to .NET types. The SftHelperComponent control can be added to a form, by locating the control in the toolbox group *"Softel vdm, Inc."*. It can be added to a form by clicking on the SftHelperComponent button of the toolbox, then clicking on the form or by dragging the SftHelperComponent button of the toolbox to the form. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/net/using2.gif) The component will not appear on the form, but will instead be shown as a component used by the form. ### Preparing a Project Add the following *Imports* and *using*** **statements to your project source file(s). This simplifies name resolution, makes most enumerated constants available and provides access to the OLECvt class. VB ``` Imports AxSftButtonLib40 Imports SftButtonLib40 Imports Softelvdm.OLEConvert ``` C# ``` using SftButtonLib40; using AxSftButtonLib40; using Softelvdm.OLEConvert; ``` All required steps have now been completed to use SftButton/OCX. For a complete example, add the following sample code to initialize the control: VB ``` Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AxSftButton1.Text = "Click Me" AxSftButton1.ShowDropDown = True End Sub ``` C# ``` private void Form1_Load(object sender, System.EventArgs e) { axSftButton1.Text = "Click Me"; axSftButton1.ShowDropDown = true; } ``` > In this example, the control is initialized at run-time using code. Of course it is also possible (and much easier) to set up all properties using the [property pages](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog). You can access the property pages by right-clicking on the control and select the *Properties...* entry of the popup menu. After adding the control to the form, right click on the control and select the *Properties**...* entry of the popup menu. This displays the Property Dialog for the control. Please note that you can right-click on a property in a Property Dialog or double-click on the description of a property to access its complete help information. This control has many properties and methods which you can use. This is a very simple example and doesn't even begin to exploit the capabilities of this control. Please take a moment to familiarize yourself with the [objects](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/i_object_hierarchy) offered by the SftButton/OCX control. Each object represents a specific area of the control and can be fully customized. Also make sure to run the [demo](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_demo_application) which is included with this product and take a look at the included [samples](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_samples). ### Special Considerations When adding SftButton/OCX to a project, Visual Studio .NET generates a class wrapper to fully support an ActiveX control such as SftButton/OCX. Unfortunately, this class wrapper is slightly incomplete and generates initially unexpected function names for certain properties. However, these issues are easily resolved. #### Picture Properties While some graphics properties are generated to use an Image type, many properties and methods do not. These use the OLE picture type stdole.IPictureDisp instead, which cannot directly be used with an Image type. The *Syntax* portion of each method, property and event shows the full syntax and required picture type (Image or stdole.IPictureDisp). The Image type can easily be converted into a stdole.IPictureDisp type using the provided class OLECvt. This class is added to each project using Softelvdm.OLEConvert (see Preparing a Project above). VB ``` Public Shared Function ToIPictureDisp(ByVal i As Image) As stdole.IPictureDisp Public Shared Function ToImage(ByVal pic As stdole.IPictureDisp) As Image ``` C# ``` public static stdole.IPictureDisp ToIPictureDisp(Image i); public static Image ToImage(stdole.IPictureDisp pic); ``` ToIPictureDisp returns a stdole.IPictureDisp pointer given an Image object. With this helper class in place, the [SftPictureObject](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/index_SftPictureObject).[Picture](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftPictureObject_Picture) property (for example) can now be used as follows: VB ``` AxSftButton1.Image1.Picture = OLECvt.ToIPictureDisp(PictureBox1.Image) ``` C# ``` AxSftButton1.Image1.Picture = OLECvt.ToIPictureDisp(pictureBox1.Image); ``` In this example, PictureBox1 is a PictureBox control, part of the form, containing an image. > If you are using the same image many times, make sure to convert it once only and use the saved stdole.IPictureDisp. Converting the same image many times will create multiple OLE Picture objects, which can deplete virtual storage and available systems resources. The *Syntax* section of picture properties typically shows *Get*, *Put* and *PutRef* forms. If both * Put* and *PutRef* are available, *PutRef* is the preferred form as it conserves resources and assigns a picture object reference to the control. *Put* causes the control to completely copy the picture object. #### Color Properties Color properties without parameters of the [SftButton object](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/index_SftButton) use the .NET Color structure, but all other properties and objects (such as SftPictureObject, etc.) use the native type UInt32 (uint). Converting a .NET Color structure color to a UInt32 (OLE color value) and vice versa is easily accomplished using the provided class OLECvt. This class is added to each project using Softelvdm.OLEConvert (see Preparing a Project above). VB ``` Public Shared Function ToOleColor(ByVal clr As System.Drawing.Color) As UInt32 Public Shared Function ToColor(ByVal clr As UInt32) As System.Drawing.Color ``` C# ``` public static uint ToOleColor(System.Drawing.Color clr); public static System.Drawing.Color ToColor(uint clr); ``` The valid range for a color value is 0 to 16,777,215 (&HFFFFFF). The high order byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte is not 0, the system colors as defined in Control Panel's settings are used. The Windows API GetSysColor defines all valid constants. Please see your development environment's documentation for applicable color constants. The * Syntax* portion of each method and property shows whether a Color structure or an OLE color value is used. Color Structure - VB ``` AxSftButton1.BackColor = SystemColors.Highlight AxSftButton1.BackColor = Color.Red AxSftButton1.BackColor = OLECvt.ToColor(&HFF) ' red Dim c As Color c = AxSftButton1.BackColor ``` Color Structure - C# ``` axSftButton1.BackColor = SystemColors.Highlight; axSftButton1.BackColor = Color.Red; axSftButton1.BackColor = OLECvt.ToColor(0x00000ff); // red ``` ``` Color c = axSftButton1.BackColor; ``` OLE Color Value - VB ``` AxSftButton1.Image1.SampleColor = OLECvt.ToOleColor(SystemColors.Highlight) AxSftButton1.Image1.SampleColor = OLECvt.ToOleColor(Color.Red) AxSftButton1.Image1.SampleColor = &HFF ' red Dim c As Color c = OLECvt.ToColor(AxSftButton1.Image1.SampleColor)) ``` OLE Color Value - C# ``` axSftButton1.Image1.SampleColor = OLECvt.ToOleColor(SystemColors.Highlight); axSftButton1.Image1.SampleColor = OLECvt.ToOleColor(Color.Red); axSftButton1.Image1.SampleColor = 0x00000ff; // red ``` ``` Color c = OLECvt.ToColor(AxSftButton1.Image1.SampleColor); ``` ### Object vs. Interface The main control is represented by an object of the SftButton class, but can also be represented by its ISftButton interface. The ISftButton interface can be retrieved using the Direct property. Certain methods and properties have different names and return types, based on how they are accessed. While (for example) an object based on the SftButton class is mostly equivalent to the ISftButton interface exposed by the control, .NET can introduce minor differences. Such differences are shown in the * Syntax* section of the affected methods and properties. All other classes are identical to their interfaces and no distinction is made. The * Syntax* portion shows both forms, the class member and the interface method (the interface method is always marked with a Note indicator). If both forms are identical, only one entry is shown. #### VB, C# Some properties (particularly font and picture properties) may require different types. For example, the Font property accepts a System.Drawing.Font when accessed through a SftButton class object, but uses a stdole.IFontDisp interface pointer when accessed directly though the ISftButton interface pointer. stdole.IFontDisp can be provided using the OLECvt class. Some properties or methods use different names, depending on how they are accessed. For example, the Refresh method is named CtlRefresh when accessed through a SftButton class object. When accessed directly though the ISftButton interface pointer it is named Refresh. Other classes, such as SftPictureObject, make no distinction between the class and interface. The class SftPictureObject is equivalent to its respective interface ISftPictureObject. ## Adding Controls To The Visual Studio Toolbox *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toolboxvs* The controls are automatically added to the Visual Studio Toolbox during installation of SftButton/OCX and are located in the toolbox group *"Softel vdm, Inc."*, except for Visual Studio .NET 2002 and all Visual Studio Express Editions. For these, the controls have to be added "manually" using the following simple procedure. Adding SftButton/OCX Adding The SftHelperComponent Component ### Adding SftButton/OCX To Visual Studio .NET 2002 and Visual Studio Express Editions For Visual Studio 2003 and above the controls are automatically added to the Visual Studio Toolbox in the toolbox group named *"Softel vdm, Inc."* and this section can be skipped. Otherwise, the SftButton/OCX control must be added to the toolbox before it can be used in a project. Open a form in your project in design view. Right-click anywhere on the Toolbox and select "Add Tab" from the popup menu. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using1.gif) This creates a new tab for the control to be added. To complete the new tab, enter a suitable tab label. In this example, we enter "*Softel vdm, Inc.*" and press Return. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using2.gif) Once the tab has been added, we are ready to add controls to it. Right-click on the area below the tab heading and select "Choose Items..." (or Add/Remove Items... in older Visual Studio versions) from the popup menu. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using3.gif) This will present the Choose Toolbox Items dialog, which is used to locate the ActiveX control you want to add. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using4.gif) Finally, click OK and the control now appears in your Toolbox. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using5.gif) ### Adding The SftHelperComponent Component For Visual Studio 2003 and above the controls are automatically added to the Visual Studio Toolbox in the toolbox group named *"Softel vdm, Inc."* and this section can be skipped. Otherwise, the SftButton/OCX control must be added to the toolbox before it can be used in a project. Open a form in your project in design view. In the toolbox, locate the group "*Softel vdm, Inc.*", created when the SftButton/OCX control was added to the toolbox (see above). Right-click on the area below the tab heading and select "Choose Items..." (or Add/Remove Items... in older Visual Studio versions) from the popup menu. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using6.gif) This will present the Choose Toolbox Items dialog, which is used to locate the .NET component you want to add. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using7.gif) The [SftHelperComponent](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_dotnet) is located at C:\Program Files\Common Files\Softelvdm\Softelvdm.Controls\ or C:\Program Files (x86)\Common Files\Softelvdm\Softelvdm.Controls on 64-bit Windows versions. Add the assembly Softelvdm.OCXHelperV2.dll. If you are using .NET 1.x, add Softelvdm.OCXHelper.dll instead. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using8.gif) Locate the assembly and click Open to accept. This will return you to the Choose Toolbox Items dialog which now shows the newly added assembly. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using9.gif) Finally, click OK and the control now appears in your Toolbox. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/toolboxvs/using10.gif) ## Using SftButton/OCX with Visual Studio (Unmanaged C/C++) *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_vc7* Adding SftButton/OCX To The Toolbox Adding SftButton/OCX To A Project Special Considerations - Picture Properties - Font Properties - Color Properties This section describes how SftButton/OCX is typically used with unmanaged C/C++ and Visual Studio .NET. All interfaces offered by SftButton/OCX, such as [ISftButton](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/index_SftButton), [ISftPictureObject](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/index_SftPictureObject), are implemented as dual interfaces. Using vtable binding is significantly more efficient than using the IDispatch interface. The approach presented here relies on the #import preprocessor directive available in Visual C++. ### Adding SftButton/OCX To The Toolbox The controls are automatically added to the Visual Studio Toolbox in the toolbox group *"Softel vdm, Inc."*, except for Visual Studio .NET 2002 and all Visual Studio Express Editions. For these, the controls have to be added "manually" using the simple procedure outlined in "[Adding Controls To The Visual Studio Toolbox](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_toolboxvs)". If you are using Visual Studio .NET 2002 or any of the Visual Studio Express Editions, please take a moment to add the controls using the simple procedure outlined in "Adding Controls To The Visual Studio Toolbox" before continuing. ### Adding SftButton/OCX To A Project Typically, the control is used with an MFC based application (or ATL). For this example, a sample MFC based application is used, but any unmanaged C or C++ application developed using Visual C++ can use this approach. This sample is created using the MFC AppWizard. A dialog based application is generated. While it is possible to use SftButton/OCX in non-dialog windows, this is rarely the case. In order to use any ActiveX controls in an MFC based project, OLE control support has to be added to the project. This is accomplished automatically when using the Application Wizard (as long as ActiveX control support is selected), or can be added later in the CWinApp::InitInstance member function, by using the AfxEnableControlContainer() function. For more information on ActiveX controls and Visual C++ please see the Visual C++ documentation. ### Adding The Control The SftButton/OCX control can be added to a form, by locating the control in the toolbox group *"Softel vdm, Inc."*. It can be added to a form by clicking on the SftButton/OCX button of the toolbox, then clicking on the form or by dragging the SftButton/OCX button of the toolbox to the form. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/vc7/using1.gif) Resize the control to a suitable size. ### Adding A Member Variable Click on the control, then invoke the Add Member Variable Wizard using the menu command *Project*, *Add Variable...*. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/vc7/using2.gif) Enter a variable name, and optional comment and click *Finish*. This will add the C++ wrapper classes needed to access SftButton/OCX. A number of C++ classes are generated for each object class supported by SftButton/OCX. The only wrapper class that is needed is the class CSftButton/OCX (based on the control's IDispatch interface). It is only needed to define the options control. Any other C++ classes generated can be discarded and are not used. ### Using #import Because the generated wrapper classes are **not** used, #import statements have to be added to Stdafx.h. The #import directive makes all interfaces and the associated methods and properties available to the application. ``` #pragma warning(disable : 4192) // automatically excluding 'Ixxx' while importing type library 'stdole2.tlb' // For information about the following construct, please see Microsoft's // KnowledgeBase entry Q224610 #import rename_namespace("SftButtonNameSpace") exclude("OLE_HANDLE", \ "OLE_COLOR", "IFontDisp", "IPictureDisp", "FONTSIZE") #import rename_namespace("SftButtonNameSpace") rename("LoadImage", "LoadImageSftButton") #if _MSC_VER >= 1400 // need at least Visual Studio 2005 # pragma comment(lib, "comsuppw.lib") // avoid link error in VS2005 #endif #pragma warning(default : 4192) using namespace SftButtonNameSpace; ``` SftButton/OCX controls are installed in the Windows System(32) directory. The #import statement generates two files, SftButton_IX86_U_30.tlh and SftButton_IX86_U_30.tli, which are automatically included into the source at the position of the #import directive. It does so by analyzing the type library which is built into the SftButton/OCX control. These files contain the definition of the methods and properties as shown in the *Syntax* section of each method and property. ``` VARIANT_BOOL Boolean = object->Enabled; ``` In addition, lower level function calls are also defined. ``` VARIANT_BOOL Boolean = object->GetEnabled(); void object->PutEnabled(VARIANT_BOOL Boolean); ``` The generated header files SftButton_IX86_U_30.tlh and SftButton_IX86_U_30.tli should be used as a reference when using the functions and C++ properties. This documentation generally includes the higher level property variables and functions only. Some low-level functions are not shown and can only be found in the generated header files. Which style is used depends on your preference. Both styles are identical in functionality but some styles are easier to use. For example, the Enabled property can be set using any of the following styles: ``` ISftButtonPtr vButton1 = m_Button1.GetControlUnknown(); vDir1->Enabled = VARIANT_FALSE; ``` or ``` ISftButtonPtr vButton1 = m_Button1.GetControlUnknown(); vDir1->PutEnabled(VARIANT_FALSE); ``` For more information on smart pointers such as ISftButtonPtr used above, please see the Visual C++ product documentation. ### Adding IntelliSense Help IntelliSense information is available for SftButton/OCX 4.0, but it is not automatically added to your projects. To "activate" IntelliSense help, add the generated header files SftButton_IX86_U_30.tlh and SftButton_IX86_U_30.tli to your project. IntelliSense is only available for files that are part of your project. Using the *Project*, *Add Existing Item... *menu command, locate the above header files in your project's directory or subdirectories and add these to your project. These files exist only after the project has been compiled at least once. ### Sample Initialization All required steps have now been completed to use SftButton/OCX. Add the following sample code to initialize the control in the OnInitDialog member function of the dialog: ``` ISftButtonPtr vButton = m_Button1.GetControlUnknown(); ``` ``` CString string(_T("Click Me")); vButton->Text = (LPCTSTR) string; vButton->ShowDropDown = VARIANT_TRUE; ``` > In this example, the control is initialized at run-time using code. Of course it is also possible (and much easier) to set up all properties using the [property pages](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog). You can access the property pages by right-clicking on the control and select the *Properties...* entry of the popup menu. You can run the sample application and it displays a SftButton/OCX with a [drop down button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dropdown). After adding the control to the form, right click on the control and select the *Properties**...* entry of the popup menu. This displays the Property Dialog for the control. Please note that you can right-click on a property in a Property Dialog or double-click on the description of a property to access its complete help information. This control has many properties and methods which you can use. This is a very simple example and doesn't even begin to exploit the capabilities of this control. Please take a moment to familiarize yourself with the [objects](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/i_object_hierarchy) offered by the SftButton/OCX control. Each object represents a specific area of the control and can be fully customized. Also make sure to run the [demo](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_demo_application) which is included with this product and take a look at the included [samples](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_samples). ### Special Considerations The #import statement generates two files, SftButton_IX86_U_30.tlh and SftButton_IX86_U_30.tli, which are automatically included into the source at the position of the #import directive. It does so by analyzing the type library which is built into the SftButton/OCX control. These files contain the definition of the methods and properties as shown in the *Syntax* section of each method and property. #### Picture Properties Applications written using C/C++ have direct access to Windows APIs and generally can manipulate bitmaps, icons and metafiles using Windows handles. ActiveX controls manipulate all pictures using the OLE Picture object represented by the IPicture and IPictureDisp interfaces. SftButton/OCX has full support for Windows handles and OLE Picture objects, so a C/C++ application can use its preferred picture representation. In addition, SftButton/OCX also support [GDI+](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus), so an application can use GDI+ images directly using properties and methods such as [SftPictureObject.Image](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftPictureObject_Image) as [SftPictureObject.LoadImage](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftPictureObject_LoadImage). #### Using Handles Most properties and methods have forms which directly accept (bitmap) handles as parameters. The [Image1](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Image1) property (for example) can be used as follows: ``` CBitmap m_Up; . . . m_Up.LoadBitmap(IDB_UP); . . . vButton->Image1->PutPictureH((OLE_HANDLE)(HBITMAP) m_Up); ``` #### Using OLE Picture Objects OLE Picture objects can be created using Windows API functions, such as OleCreatePictureIndirect. ``` IPictureDispPtr pPic; PICTDESC PictDesc; PictDesc.cbSizeofstruct = sizeof(PICTDESC); PictDesc.picType = PICTYPE_BITMAP; PictDesc.bmp.hbitmap = (HBITMAP) bitmap_handle; PictDesc.bmp.hpal = NULL; HRESULT hr = OleCreatePictureIndirect(&PictDesc, __uuidof(pPic)/*IID_IPictureDisp*/, FALSE, (void**)&pPic); ASSERT(SUCCEEDED(hr)); . . . vButton->Image1->PutRefPicture(pPic); ``` The *Syntax* section of picture properties typically shows *Get*, *Put* and *PutRef* forms. If both * Put* and *PutRef* are available, *PutRef* is the preferred form as it conserves resources and assigns a picture object reference to the control. *Put* causes the control to completely copy the picture object. #### Font Properties Fonts are represented using the OLE Font object and the IFontDisp interface. OLE Font objects can be created using the Windows API function OleCreateFontIndirect. The [SftButton.Font](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftButton_Font) property (for example) can be used as follows: ``` FontPtr pFont = vButton->GetFont(); pFont->Name = _T("MS Sans Serif"); pFont->Weight = FW_BOLD; pFont->Italic = VARIANT_FALSE; CY size; size.int64 = 100000;// point size * 10000 pFont->Size = size; ``` The *Syntax* section of font properties typically shows *Get*, *Put* and *PutRef* forms. If both * Put* and *PutRef* are available, *PutRef* is the preferred form as it conserves resources and assigns a font object reference to the control. Any change to the font object is reflected in the control also. *Put* on the other hand causes the control to completely copy the font object. #### Color Properties The valid range for a color value is 0 to 16,777,215 (0xffffff). The high order byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (0xff). If the high byte is not 0, the system colors as defined in Control Panel's settings are used. The Windows API GetSysColor defines all valid constants. Please see your development environment's documentation for applicable color constants. ``` vButton->BackColor = 0x80000000L | COLOR_HIGHLIGHT; vButton->BackColor = 0x000000ffL; ``` ## Using SftButton/OCX with Visual Basic 6 *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_vb6* Adding SftButton/OCX To A Project Special Considerations - Color Properties ### Adding SftButton/OCX To A Project The SftButton/OCX control must be added to the Toolbox before it can be used in a project. The Toolbox normally displays the standard Visual Basic controls and any other ActiveX controls that have been added previously. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/vb/using1.gif) The control is added to the Toolbox using the *Project*, *Components...* menu command, which displays the following dialog: ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/vb/using2.gif) Select the control "SftButton/OCX 4.0 Button Control" by placing a check mark next to it and click OK. This adds the control to the Toolbox. If you don't see the control in the list, make sure *Selected Items Only* is not checked. Once you click Apply or OK and an error message is displayed, the product SftButton/OCX is not correctly installed or the control may have been unregistered accidentally. Quit Visual Basic and use the entry * Maintenance*, *Register SftButton OCX in Windows Registry* in the *SftButton OCX 4.0* program group to register the control. Restart Visual Basic and try to add the control to the Toolbox again. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/sftbuttonsm.gif) for use with **Visual Basic** (and [other development tools](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_other)) Now the control can be added to a form by clicking on the SftButton/OCX button of the Toolbox. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/vb/using3.gif) All required steps have now been completed to use SftButton/OCX. Add the following sample code to initialize the control: ``` Private Sub Form_Load() With SftButton1 .Text = "Click Me" .ShowDropDown = True End With End Sub ``` You can run the sample application and it displays a SftButton/OCX with a [drop down button](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_dropdown). After adding the control to the form, right click on the control and select the *Properties**...* entry of the popup menu. This displays the [Property Dialog](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog) for the control. Please note that you can right-click on a property in a Property Dialog or double-click on the description of a property to access its complete help information. This control has many properties and methods which you can use. This is a very simple example and doesn't even begin to exploit the capabilities of this control. Please take a moment to familiarize yourself with the [objects](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/i_object_hierarchy) offered by the SftButton/OCX control. Each object represents a specific area of the control and can be fully customized. Also make sure to run the [demo](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_demo_application) which is included with this product and take a look at the included [samples](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_samples). ### Special Considerations #### Color Properties The valid range for a color value is 0 to 16,777,215 (&HFFFFFF). The high order byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte is not 0, the system colors as defined in Control Panel's settings are used. The Windows API GetSysColor defines all valid constants. Please see your development environment's documentation for applicable color constants. ``` SftButton1.BackColor = vbHighlight SftButton1.BackColor = vbRed SftButton1.BackColor = &HFF ' red ``` ``` Dim c As Long c = SftButton1.BackColor ``` ## Using SftButton/OCX with Other Development Tools *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_other* SftButton/OCX is designed according to the latest ActiveX standards and can be used with a wide variety of development tools. While these are not documented here, the product can be used with most development tools that support ActiveX controls. Most development tools document how to use an ActiveX control, so you should be able to find information specific to your development tool in its documentation. While many development tools support ActiveX controls, some may encounter specific problems and restrictions. These can generally not be addressed by our control product. [OLE drag & drop](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_oledragdrop) in particular may be limited or unavailable. Our product fully supports the most popular languages, such as Visual Basic, VB.NET, C#, Visual C++, Microsoft Access, Delphi, etc. ## Property Dialogs *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog* ### Overview Depending on the development environment used, the steps necessary to modify the control properties vary. The properties supported by the control can be displayed in a variety of ways. See your development environment's documentation for specific instructions. Usually, development tools allow access to the Property Pages implemented by a control. For example, Visual Basic allows you to right-click on the control in design mode. By selecting *Properties'* from the popup menu presented, the properties can be accessed using the Property Pages provided by the control. The following tabs are offered by this property dialog. Additional tabs may be added to the dialog by your development tool. | Tab | Description | | --- | --- | | Attributes | Defines the main attributes of the control. | | QuickSetup | Defines property page dialog options. | | Load/Save Settings | Used to load or save the settings for the currently selected control. | | Options | Defines property page dialog options. | | Updates | Download free product maintenance and updates | Each tab and associated page allows a set of properties to be manipulated. All properties are labeled using the property name. Detailed descriptions can be found in the on-line help. ### Help By right-clicking on the property page, help information for a specific property can be accessed. Most pages offer on-line help by clicking on the Help button. This Help button may not be displayed when using certain development environments. Other means may be available to view the SftButton/OCX on-line help. ### Property Pages Each property page shows a number of properties using categories (such as Appearance, Behavior, Colors, etc.). By clicking on a property, the property can be edited. Using the TAB (or SHIFT+TAB) key the next (or previous) property can be edited or simply click on another property. Double-click on the description of a property to display the complete help information or right-click on the property grid for a help menu. ### Color Properties When clicking on a property representing a color value, a combo box is displayed which shows the available system colors as defined using Control Panel and also the basic colors. A new color value can be selected from the choices offered or a new color value can be entered. The following syntax is accepted: | Syntax | Description | | --- | --- | | &H00*bbggrr*& | A hexadecimal number (Visual Basic style) | | 0x00*bbggrr* | A hexadecimal number (C/C++ style) | | *decimal* | A decimal value, the decimal equivalent of a hexadecimal color value | | | | | where | *bb* = blue component *rr* = red component *gg* = green component | | | | | **Example:** | &H00FF0000& (Blue) | | | 0x0000ff00 (Green) | The display format of color values can be modified using the Options page. ### Image Properties An image property (based on a [SftPictureObject object](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/index_SftPictureObject) class) can be defined by clicking on the![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/dropbutt.gif) bitmap of the cell. This displays a dialog that is used to load a bitmap, [GDI+](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus) image, icon or metafile, built-in image or [color sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/SftPictureObject_SetColorSample). Some properties only allow bitmaps or only icons. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/propimage.gif) If a file has been loaded, the image is saved along with the control properties and the file is no longer required. Image properties display (None), (GDI+ Image), (Picture), (Built-In), (Color Sample) or (Invalid Type), depending on the graphic type loaded. To clear an image property click on the![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/dropbutt.gif) bitmap of the cell, then click Clear on the resulting dialog. This will clear the image property. ### Picture Properties A Picture property can be defined by clicking on the![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/dropbutt.gif) bitmap of the cell. This displays a dialog that is used to load a bitmap, icon or metafile. Some properties only allow bitmaps or only icons. ![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/proppicture.gif) Once a file has been loaded, the image is saved along with the control properties and the file is no longer required. Picture properties display (None), (Bitmap), (Metafile), (Icon) or (Invalid Type), depending on the graphic type loaded. To clear a Picture property click on the![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/dropbutt.gif) bitmap of the cell, then click Cancel on the resulting dialog. This will clear the Picture property. ### Font Properties A Font property can be defined by clicking on the![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/dropbutt.gif) bitmap of the cell. This displays a dialog that is used to define the attributes of the font. Certain font properties also support the use of a default font. To restore the default font, right-click on the![](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/dropbutt.gif) bitmap of the cell and select the *Reset* menu entry. ## Attributes - Property Page *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_props_attributes* Defines the main attributes of the control. Double-click on the description of a property to display the complete help information or right-click on the [property dialog](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog) for a help menu. For general information on how to use property pages, please see Property Dialogs. ## QuickSetup - Property Page *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_props_quicksetup* Provides quick setup of frequently used edit control styles. Select a style, then click on the "Go" button to update the current control by setting its properties. The [property pages](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog) can then be used to further customize the control. For general information on how to use property pages, please see Property Dialogs. ## Load/Save Settings - Property Page *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_props_savesettings* The Load/Save buttons are used to load or save the settings for the currently selected control. This is best used to transfer settings between different controls (of the same type). It is not necessary to save controls that are on a form as these settings are automatically saved when the form is saved. Using the Load/Save [property page](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog) is usually only used when you need to transfer settings between already existing controls. For general information on how to use property pages, please see Property Dialogs. ## Options - Property Page *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_props_options* The Options dialog allows you to change defaults of the [property dialogs](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog). Switching between different size property pages will not take effect until the property pages are ** closed and reopened**. Some IDE's (Visual Studio 6.0) must be closed and restarted before the changes take effect. Checking for available updates requires an Internet connection. Certain systems settings and site firewalls may prevent automatic update checking. In that case, use the Updates property page instead to check for available updates. ## Updates - Property Page *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_props_updates* Click on the "Free Updates..." button to download free product maintenance and updates from our web site. The product will contact our web site and check whether a newer version of the product is available. If product maintenance is available, you can download and install it automatically. Internet access is required to use the automatic download and update feature provided by this product. For general information on how to use [property pages](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/r_property_dialog), please see Property Dialogs. ## Demo Application *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_demo_application* During the installation of SftButton/OCX, an icon for the demo application "Demo" is installed in the program group *SftButton OCX 4.0*. This demo application shows some of the features available in SftButton/OCX. It is also used to access other [samples](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_samples) included in the demo or product and the online help. ![Demo Application](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20OCX%204.0/image/demo1.png) > All sample programs and complete sample source code can be found in the directory \Program Files\Softelvdm\SftButton OCX 4.0\Samples or \Program Files (x86)\Softelvdm\SftButton OCX 4.0\Samples (64-bit Windows versions). Each sample is installed in its own subdirectory. All samples are supplied with a precompiled executable (EXE) and an entry is added to the *SftButton OCX 4.0* program group for each sample. ## Samples *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_samples* SftButton/OCX includes sample code for both VB.NET, C#, VB6 and C++/MFC. Even though C samples are not included, the Syntax section for properties, methods and events also shows the C syntax. The following samples can be found in the folder C:\Program Files\Softelvdm\SftButton OCX 4.0\Samples: ### VB.NET | Sample | Description | | --- | --- | | [VB.NET Animations Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vbnet_animations) | Illustrates AVI animations with AVIPlay method. | | [VB.NET Images Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vbnet_images) | Illustrates button states and images. | | [VB.NET Label Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vbnet_label) | Illustrates various button labels, text, images. | | [VB.NET Popup Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vbnet_popup) | Illustrates drop down buttons and popup menus. | | [VB.NET Special Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vbnet_special) | Illustrates special effects. | | [VB.NET Toggle Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vbnet_toggle) | Illustrates toggle buttons. | ### C# | | | | --- | --- | | [C# Animations Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_cs_animations) | Illustrates AVI animations with AVIPlay method. | | [C# Images Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_cs_images) | Illustrates button states and images. | | [C# Label Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_cs_label) | Illustrates various button labels, text, images. | | [C# Popup Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_cs_popup) | Illustrates drop down buttons and popup menus. | | [C# Special Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_cs_special) | Illustrates special effects. | | [C# Toggle Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_cs_toggle) | Illustrates toggle buttons. | ### C++ | | | | --- | --- | | [C++ Animations Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vc_animations) | Illustrates AVI animations with AVIPlay method. | | [C++ Images Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vc_images) | Illustrates button states and images. | | [C++ Label Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vc_label) | Illustrates various button labels, text, images. | | [C++ Popup Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vc_popup) | Illustrates drop down buttons and popup menus. | | [C++ Special Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vc_special) | Illustrates special effects. | | [C++ Toggle Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vc_toggle) | Illustrates toggle buttons. | ### VB6 | | | | --- | --- | | [VB6 Animations Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vb6_animations) | Illustrates AVI animations with AVIPlay method. | | [VB6 Images Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vb6_images) | Illustrates button states and images. | | [VB6 Label Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vb6_label) | Illustrates various button labels, text, images. | | [VB6 Popup Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vb6_popup) | Illustrates drop down buttons and popup menus. | | [VB6 Special Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vb6_special) | Illustrates special effects. | | [VB6 Toggle Sample](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/samples_vb6_toggle) | Illustrates toggle buttons. | ## Distributing SftButton/OCX *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_distributing* This section describes the preferred distribution method when shipping SftButton/OCX with your application. This method follows Microsoft's guidelines on ActiveX control distribution. While these guidelines are not enforced, it is highly recommended that they are followed as outlined here. This insures that your application can be safely installed and use SftButton/OCX even if another vendor has already installed an application which also uses SftButton/OCX. > Supported platforms include Windows 10, Windows 11 and their server editions. ### Installing SftButton/OCX (for an Application) When distributing SftButton/OCX with your application, only the following files can be distributed with your application royalty-free. These files allow the use of the control with your application. The design-time interface is no longer available once SftButton/OCX is shipped with your application. For additional information regarding distributing this control with your application, see the license agreement. ### Required Files **Important:*** *Redistributable files are located in the SftButton/OCX installation directory (\Program Files\Softelvdm\SftButton OCX 4.0\Redist). These files must be shipped with your application if SftButton/OCX is used: | File Name | Target Folder | Description | | --- | --- | --- | | SftButton_IX86_U_40.ocx | See Control Target Directory below | **Required for 32-bit applications.** SftButton/OCX control. When distributing a managed .NET application compiled for "Any CPU", the 32-bit and 64-bit control must be distributed. | | SftButton_x64_U_40.ocx | See Control Target Directory below | **Required for 64-bit applications.** SftButton/OCX control. When distributing a managed .NET application compiled for "Any CPU", the 32-bit and 64-bit control must be distributed. | | Softelvdm.OCXHelperV2.dll | See [SftHelperComponent](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using_dotnet) Target Directory below | **Required for .NET 2.0 and above ONLY.** This .NET component is required when distributing managed .NET applications. It is not used for other (unmanaged) languages, like VC++, VB6, etc. This file requires the .NET 2.0 runtime (or newer). If your application uses the 2.0 runtime (or newer), this file needs to be distributed with your application. | | Softelvdm.OCXHelper.dll | See SftHelperComponent Target Directory below | **Required for .NET 1.x ONLY.** This .NET component is required when distributing a managed .NET applications which requires the .NET 1.x runtime. It is not used for other (unmanaged) languages, like VC++, VB6, etc. If your application uses the 1.x runtime, this file needs to be distributed with your application. | | Softelvdm.NETHelper.dll | Application Folder | **Required for .NET 4.0 and above ONLY - Applications compiled for "Any CPU" or "x86".** This dll is required when distributing managed .NET applications. It is not used for other (unmanaged) languages, like VC++, VB6, etc. This file is required if your application uses the .NET 4.0 runtime or newer and is compiled for "Any CPU" or "x86". If your application is compiled for "Any CPU" you will need both Softelvdm.NETHelper.dll and Softelvdm.NETHelper_x64.dll. If your application uses the 2.0 runtime or is compiled for "x86", this file can optionally be distributed with your application, but it is not required. | | Softelvdm.NETHelper_x64.dll | Application Folder | **Required for .NET 4.0 and above ONLY - Applications compiled for "Any CPU" or "x64".** This dll is required when distributing managed .NET applications. It is not used for other (unmanaged) languages, like VC++, VB6, etc. This file is required if your application uses the .NET 4.0 runtime or newer and is compiled for "Any CPU" or "x64". If your application is compiled for "Any CPU" you will need both Softelvdm.NETHelper.dll and Softelvdm.NETHelper_x64.dll. If your application uses the 2.0 runtime or is compiled for "x86", this file can optionally be distributed with your application, but it is not required. | | Oleaut32.dll | \Windows\System32 or \Windows\SysWow64 | Required. OLE support. While normally present, the installation must insure that the current version is installed. This file is also needed by the container (VB, VC++, etc.) to support OLE and any ActiveX control. | | Olepro32.dll | \Windows\System32 or \Windows\SysWow64 | Required. OLE property and standard types support. While normally present, the installation must insure that the current version is installed. This file is also needed by the container (VB, VC++, etc.) to support OLE and any ActiveX control. | | Stdole2.tlb | \Windows\System32 or \Windows\SysWow64 | Required. OLE support. While normally present, the installation must insure that the current version is installed. This file is also needed by the container (VB, VC++, etc.) to support OLE and any ActiveX control. | | Asycfilt.dll | \Windows\System32 or \Windows\SysWow64 | Required. OLE support. While normally present, the installation must insure that the current version is installed. This file is also needed by the container (VB, VC++, etc.) to support OLE and any ActiveX control. | | Comcat.dll | \Windows\System32 or \Windows\SysWow64 | Required. OLE support. While normally present, the installation must insure that the current version is installed. This file is also needed by the container (VB, VC++, etc.) to support OLE and any ActiveX control. | | Regsvr32.exe | any | Optional. Control registration utility, for "manual" registration. Not needed with most commercial Setup creation tools. | ### GDI+ (Optional) Certain features of the control require [GDI+](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_gdiplus) support. GDI+ is available automatically on all supported Windows platforms. If GDI+ support is not available, the features are simply disabled and alternate presentation methods are used, if necessary. ### Control Target Directory Depending on the target operating systems, one of the following target directories can be chosen. #### A) Windows\System(32) Installing the ActiveX control into the Windows\System32 directory (or Windows\SysWOW64 for 32-bit controls on Windows x64) directory is possible on all supported Windows platforms. The setup program you provide with your application should install the SftButton/OCX control SftButton_IX86_U_40.ocx into the Windows System32 directory. The Windows System directory name can be found using the GetSystemDirectory API function. All other files shown in the above tables also have to be installed into the Windows System32 directory, usually named C:\Windows\System32 (or Windows\SysWOW64 for 32-bit controls on Windows x64). The control is installed into the Windows/System32 directory and registered using proper versioning and reference counting of the OCX file (usually automatic, with most commercial installers). #### B) Application Directory An ActiveX control can be installed in the application directory using DLL/COM redirection. DLL/COM redirection is activated on an application-by-application basis by the presence of a ".local" file. The ".local" file is an empty file in the same directory as the application's .exe file, with the same name as the application's .exe file with ".local" appended to the end of the name. For example, to activate DLL/COM redirection for an application called "SampleApp.exe", create an empty file called "SampleApp.exe.local" in the same directory where SampleApp.exe is installed. "Registration-Free Activation" (see below) can be used, which eliminates the need for the ".local" file. Once DLL/COM redirection is activated, whenever the application loads a DLL or an OCX, Windows looks first for the DLL or OCX in the directory where the application's .exe file is installed. If a version of the DLL or OCX is found in the directory where the application's .exe file is installed, the application uses it regardless of any directory path specified in the application or the registry. If a version of the DLL or OCX is not found in the directory where the application's .exe file is installed, the normal search path or server path is used. Even if DLL/COM redirection is used, the control must be registered during installation (see "Registering SftButton/OCX" below). The control must be installed into the Windows/System(32) directory and registered using proper versioning and reference counting of the OCX file (usually automatic, with most commercial installers). In addition, a private copy in your application directory is always installed (but not registered), along with the application's ".local" file. ### SftHelperComponent Target Directory The SftHelperComponent (see "Using SftButton/OCX with .NET") is used by .NET applications. Earlier releases of SftButton/OCX required this component to be registered using Regasm.exe for COM Interop. This is no longer required. Simply copy the file Softelvdm.OCXHelperV2.dll (or Softelvdm.OCXHelper.dll) to one of the following locations. They are listed in the order they are searched. Softelvdm.OCXHelperV2.dll: - Same folder where the ActiveX control is installed (see Control Target Directory above) - \Program Files\Common Files\Softelvdm\Softelvdm.Controls or \Program Files (x86)\Common Files\Softelvdm\Softelvdm.Controls (32-bit applications on 64-bit Windows versions only) - \Windows\System32 \Windows\SysWow64 (32-bit applications on 64-bit Windows versions only) Softelvdm.OCXHelper.dll: - Same folder where the ActiveX control is installed (see Control Target Directory above) - \Program Files\Common Files\Softelvdm\Softelvdm.Controls or \Program Files (x86)\Common Files\Softelvdm\Softelvdm.Controls (32-bit applications on 64-bit Windows versions only) - \Windows\System32 \Windows\SysWow64 (32-bit applications on 64-bit Windows versions only) The actual path (\Program Files or \Windows) may differ due to localization. ### Version Control The setup program should only install the SftButton/OCX files if the version number in the new files is higher than the files already installed. Maintenance releases of the product are fully upward compatible and are guaranteed to have a newer version number. New versions of the product will use new file names and new GUIDs so there will be no conflict between different (major) versions, such as 2.5, 3.0 and 4.0. ### Reference Counting When installing DLLs or OCX files into a "shared" location, such as the Windows\System32 or \Windows\SysWOW64 directory, proper reference counting must be performed, to insure that the file isn't uninstalled until all applications making use of the DLL or OCX have also been uninstalled. Reference counting is generally available with most commercial installers. The Windows Registry contains a count of all such shared files in the following Registry location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs ### Registering SftButton/OCX Depending on the target operating systems, one of the following ActiveX/COM registration methods can be selected. #### A) Windows Registry Registering the ActiveX control in the Windows Registry is possible on all supported Windows platforms. The setup program should register SftButton/OCX in the Windows registration database (Registry). This can be done manually using Regsvr32.exe which is discouraged. Many commercially available setup programs can register SftButton/OCX during the installation of your application. Please keep in mind that 64-bit versions of Windows have two versions of RegSvr32.exe. \Windows\System32\RegSvr32.exe is used to register 64-bit controls and \Windows\SysWOW64\RegSvr32.exe is used to register 32-bit controls. RegSvr32.exe must be run with elevated privileges as administrator. SftButton/OCX is a self-registering ActiveX control. By using the LoadLibrary Windows API function, the GetProcAddress API can be used to obtain the DllRegisterServer function. By calling this function, the SftButton/OCX control will register itself with the Windows registration database (Registry). Most commercially available setup programs have support for this built-in. Check the documentation of your setup application for information on how to install ActiveX controls. Please keep in mind that an application using the LoadLibrary API can only load the control of the same machine type, meaning a 32-bit application can only load and register 32-bit controls, a 64-bit application can only load 64-bit controls. The following files need to be registered in this manner: | File Name | Description | | --- | --- | | SftButton_IX86_U_40.ocx | Required for 32-bit applications. SftButton/OCX control | | SftButton_x64_U_40.ocx | Required for 64-bit applications. SftButton/OCX control | | Comcat.dll | OLE support | | Oleaut32.dll | OLE support | | Olepro32.dll | OLE support | #### B) Registration-Free Activation It is possible to deploy this ActiveX control using "Registration-Free Activation". Registration-free activation allows distribution of the control without the requirement to register the ActiveX control in the Windows Registry (using REGSVR32 or a Setup application). Registration-free activation is supported by the operating system, so the .NET run-time is not required for registration-free activation. By using registration-free activation, true XCOPY deployment is possible. Your application uses its own copy of the control. Versioning, reference counting and registration of the control are completely eliminated and other installed versions of the control cannot interfere with your application. By using an application manifest and copying the OCX file SftButton_IX86_U_40.ocx into your application directory, the ActiveX control is automatically registered when it is used the first time. Your application manifest must include the comClass and typelib definitions shown below. These insure that your application automatically registers the control and uses the control located in your application directory, regardless of any other controls or other versions of the same control already installed or in use. ``` SftButton Sample Application ``` ### Testing a Setup Program If you test the installation of your application's Setup program on a system where the development version of SftButton/OCX is installed, you may notice that you can no longer use SftButton/OCX in your development environment. This is caused by the fact that your Setup program installed a "run-time only" control on your system, which has replaced the "design-time" or development version of SftButton/OCX. You can reinstate (or re-register) the design-time version of SftButton/OCX by using the program entry *"Maintenance, Register SftButton OCX in Windows Registry"* in the SftButton* OCX 4.0 *program group. ## Technical Support - SftButton/OCX 4.0 *Source: https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_contactsoftel* ### Product Updates New major versions and product maintenance are available with an active [support subscription](https://softelvdm.com/About/Support%20Subscription). Your product purchase includes the first year's support subscription at no extra charge. After the first year, the support subscription can be renewed for continued availability of major versions and product maintenance. While your support subscription is active, free product maintenance for the current release is available from our web site. Such free updates usually don't include any [new features](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_newfeatures) as a new release would, but include product and documentation fixes and corrections. In addition, new major and minor versions are also available at no extra charge for the duration of your active support subscription. You can download updates by using the *Product Update* entry in the *SftButton/OCX 4.0* program group of the Start menu or from the * Product Updates* link on the About dialog. ### Before Contacting Product Support A comprehensive help files can assist you in [using SftButton/OCX](https://softelvdm.com/Documentation/SftButton%20OCX%204%200/Topic/g_using). If you have difficulties using SftButton/OCX, please use the following sources of information: - Obtain help using the documentation provided at [https://softelvdm.com/Documentation/SftButton OCX 4 0](https://softelvdm.com/Documentation/SftButton%20OCX%204%200). - Review support information or download product maintenance from our web site at [https://softelvdm.com/Product/Support/Name/SftButton%20OCX%203%200?ProductId=1006](https://softelvdm.com/Product/Support/Name/SftButton%20OCX%203%200?ProductId=1006). If this does not resolve your problem, please contact Softel vdm, Inc. Product Support. ### Contacting Product Support If you have reviewed the product documentation, please contact Softel vdm, Inc. Product Support. For current contact information please visit [https://softelvdm.com/support](https://softelvdm.com/support). **IMPORTANT: **Please include your license number in all cases. Without your license number, we will not be able to help you. Your license number is printed on your installation media (CD) or you may have received it as part of your online delivery.