# SftButton/DLL 3.0 — Full Documentation > SftButton/DLL is a DLL-based button control for the Windows™ operating system, offering a fully customizable replacement for the standard Windows push button, check box and dropdown button. Online documentation: https://softelvdm.com/Documentation/SftButton%20DLL%203%200 Complete API reference (separate file): https://softelvdm.com/Vault/Softelvdm.com/llms/SftButton-DLL-3.0-reference.txt ## SftButton/DLL - Button Control *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/1_product_description* SftButton/DLL is a DLL-based button control for the Windows™ operating system, offering a fully customizable replacement for the standard Windows push button, check box and [dropdown button](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown). ### Button Control SftButton/DLL offers many features; from a simple, [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text)-only push button to a fully themed, gradient-filled button with multi-state images and an attached dropdown arrow. - [SftButton/DLL Wizard](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_wizard) for designing button controls and generating run-time code - Push button, [toggle](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_toggle) (check box) and dropdown button behavior - Three [border styles](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_borders) (thin, standard, single-pixel) - Customizable background with solid color or gradient fill (per-state: normal, focus, [hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover)) - Two overlaid image layers plus independent background pictures, each with per-state images for normal, hover, pressed and disabled - Bitmap, icon, image list and [GDI+](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus) image support through the [SFT_PICTURE](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_picture) model - Rich single-line or multi-line text through the [SFT_TEXT](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_text) model, with per-state text [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients) (normal, pressed, disabled) on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) - Selectable text alignment (left, right, center) with vertical positioning - Themes support (full, or theme-without-text) - Optional dropdown arrow in four styles (standard, narrow 1/2/3, wide 1) with its own click and double-click notifications - Configurable hit-testing regions (entire control, exact image + text bounds, images only, text only) - Hover detection (control level or pixel-exact) - [Press animation](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_bouncing) ("bounce") with per-control override - [Anchor](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_autosize)-based auto-sizing to nine window positions (corners, edges, center) - Focus ring control and default-button styling - Right-click, middle-click and double-click notifications in addition to the standard click - Complete implementation, not a sub/superclassed Windows control - Support for C and C++ (MFC) using Visual Studio - Support for Windows 10 and above, 64-bit, 32-bit and ARM64 applications - [Windows dark mode](https://softelvdm.com/Documentation/SftDarkMode/Topic/1_main) support, tracking the Windows "Choose your mode" setting automatically - [Windows High Contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast) [accessibility](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_accessibility) support - Per-Monitor v2 [DPI](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dpi) awareness with image and pixel scaling - Built-in UI Automation provider for screen readers (Narrator, NVDA, JAWS) - Documentation for AI coding assistants - an offline, full-text [API](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_api) reference formatted for large-language-model grounding, plus an AGENTS.md pointer file, so assistants such as Claude, GitHub Copilot and Cursor can answer questions and generate code against the complete API ### SftButton/DLL Wizard Application The SftButton/DLL Wizard allows you to design and test a button control without any programming. Button text, colors, borders, the dropdown arrow, images and other attributes are just a few of the items you can customize. Once you are satisfied with your button control look, the SftButton/DLL Wizard can even generate the required run-time code for C or C++ with MFC. So your programming effort is kept to a minimum. ### Source Code The source code for the MFC classes for button control access is supplied. Any application that you develop can use SftButton/DLL royalty-free (some restrictions apply), as long as only the DLL is shipped with your application. ### Languages Supported SftButton/DLL supports C, C++ and other languages when using the standard SendMessage Windows API. The DLLs can be called using the definitions provided in the supplied header file. In addition, SftButton/DLL is shipped with class definitions which support the Microsoft Foundation Class Library (MFC). ### Environments Supported - 64-bit support when running Windows 10 and above with Intel 64-bit processors - 32-bit applications on Windows 10 and above - ARM64 support when running Windows 11 and above on ARM64 processors UNICODE support is available for all platforms. The product supports the same easy to use API on all platforms. ### Royalties Any application that you develop can use SftButton/DLL royalty-free in run-time only mode; design-time features are not available. Each user (developer) who needs access to any portion of the product must license a copy of SftButton/DLL. ### AI / LLM Documentation The complete SftButton/DLL 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. ## Installing SftButton/DLL *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_installation* When you are ready to install SftButton/DLL: 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 from our web site. Both the product and demo setup applications are identical and can be used interchangeably. 2. Follow the instructions on the installation dialogs. Please note that the single developer version of SftButton/DLL can only be installed by one user on one system. Multiple developer licenses and site licenses are available. Contact Softel vdm, Inc. 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%20DLL%203%200/Topic/g_contactsoftel), such as free maintenance versions, and you will receive information regarding new releases. 4. Once SftButton/DLL has been successfully installed, you will find a new program group * SftButton DLL 3.0*. Entries for the SftButton/DLL sample applications have been added. ## Components *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_components* A SftButton control is composed of a fixed set of rendering layers drawn in a predictable order. Understanding the layer stack makes it easier to choose which fields on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) to set for a given visual effect. ### Layer stack, outside in - **Border** - one of three styles (thin, standard, single-pixel). See [Borders](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_borders). - **Background** - solid color, or a two-color gradient. Separate normal / [hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover) / pressed / focus background [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients) are available. See Colors and Gradients. - **Background pictures** (*PictureBG* / *PictureBGHover* / *PictureBGPressed* / *PictureBGDisabled*) - drawn over the background fill, under the foreground layers. - **Foreground image layer 1** (*Picture1* and its per-state variants) - the primary image. - **Foreground image layer 2** (*Picture2* and its per-state variants) - the secondary image, drawn over layer 1. - **[Text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text)** - rendered from [SFT_TEXT](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_text) in the current state's text color and font. See Text and Fonts. - **Focus ring** - drawn on top when the button has keyboard focus. - **[Dropdown arrow](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown)** (if *fShowDropDown* is TRUE) - drawn in a sidebar at the right edge of the button. See Dropdown Button. ### When theme is active When *nUseThemes* is [SFTBUTTON_THEME_YES](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_theme), Windows paints the border and background; the control draws images and text on top. *nUseThemes* SFTBUTTON_THEME_YES_NOTEXT is a hybrid - Windows paints the border and background but the control paints the text in the caller-supplied color and font. ### When dark mode or high contrast is active Theme-driven chrome is suppressed. The control falls back to its built-in GDI render path and uses a dark palette ([dark mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode)) or system colors ([high contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast)). See Dark Mode and High Contrast. ## Button States *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_button_states* A SftButton control is always in one of four rendering states. The state selects which set of per-state fields on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) the control draws from. | State | When active | Fields used | | --- | --- | --- | | **Normal** | The default state. The mouse is not over the button, the button is not being held down, and the button is enabled. | *Picture1*, *Picture2*, *PictureBG*, *colorBg* (or *colorBgStart* / *colorBgEnd*), *colorFg* | | **[Hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover)** | The mouse is over the button and hover detection fires (see Hover Detection). | *Picture1Hover*, *Picture2Hover*, *PictureBGHover*, *colorBgHover* (or *colorBgHoverStart* / *colorBgHoverEnd*) | | **Pressed** | The user is holding the primary mouse button down over the button, or the button is in its [toggle](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_toggle)-pressed state (*fToggle* and *fPressed* both TRUE). | *Picture1Pressed*, *Picture2Pressed*, *PictureBGPressed*, *colorBgPressed*, *colorFgPressed* | | **Disabled** | The button has been disabled through *WS_DISABLED* / *EnableWindow*. | *Picture1Disabled*, *Picture2Disabled*, *PictureBGDisabled*, *colorFgGrayed* | ### Fallback If a per-state image is not set, the control falls back to the matching field from the normal state. That way you only need to populate Hover / Pressed / Disabled variants when you want them to differ from Normal. [Text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) uses a single [SFT_TEXT](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_text) field that applies to every state - *colorFg* / *colorFgPressed* / *colorFgGrayed* provide the per-state text [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients). ### Focus Focus is orthogonal to the four states above. A focused button uses the *colorBgFocus* (or *colorBgFocusStart* / *colorBgFocusEnd*) gradient when no other state overrides it. The focus rectangle is drawn on top regardless of state, unless *fHideFocus* is TRUE. ### Dark mode and high contrast The four-state model is unchanged in [dark mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode) and [high contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast) - the same per-state pictures are drawn. Caller-supplied colors are honored in dark mode and overridden by the system palette in high contrast. See Dark Mode and High Contrast. ## Button Images *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_button_images* SftButton supports three independent image layers, each with its own per-state pictures. Every picture field is an [SFT_PICTURE](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_picture) structure that can reference a bitmap, icon, image list entry, check-box / radio-button style, or (when [GDI+](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus) is available) a PNG / TIFF / JPEG / GIF / EMF image. ### Layers and fields | Layer | Per-state fields | Drawn | | --- | --- | --- | | Background pictures | *PictureBG*, *PictureBGHover*, *PictureBGPressed*, *PictureBGDisabled* | Over the background fill, under the foreground layers | | Foreground image 1 | *Picture1*, *Picture1Hover*, *Picture1Pressed*, *Picture1Disabled* | Over the background pictures | | Foreground image 2 | *Picture2*, *Picture2Hover*, *Picture2Pressed*, *Picture2Disabled* | Over foreground image 1 | ### Fallback [Hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover), Pressed and Disabled variants are optional. If a per-state field is left empty, the control falls back to the base variant. A button that only defines *Picture1* renders the same image in every state. ### Transparency Bitmaps are automatically made transparent by inspecting the top-left pixel - see [Bitmap Transparency](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_bitmap_transparency). Icons, image list entries and GDI+ images preserve their native transparency. Alpha-blended GDI+ images (PNG with transparency, TIFF, EMF+) render correctly over [gradients](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients) and background pictures. ### Image scaling and DPI By default, images are scaled by *currentDPI / 96* so a single set of 96-[DPI](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dpi) bitmaps renders at the right physical size on any monitor. Applications that ship pre-scaled images and want them drawn at their native pixel size can call [SetImageScaling](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setimagescaling) with [SFTBUTTON_IMAGESCALING_ASIS](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_imagescaling). See Per-Monitor DPI and Scaling. ## Text and Fonts *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text* Button text is rendered from a single [SFT_TEXT](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_text) field on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) - *Text*. Per-state appearance comes from the per-state foreground [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients) on SFTBUTTON_CONTROL itself: *colorFg* (normal and [hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover)), *colorFgPressed* (pressed) and *colorFgGrayed* (disabled). ### Content SFT_TEXT holds the text value as a null-terminated string. Ampersands (*&*) in the text specify the accelerator key - pressing Alt+the-letter-after-ampersand invokes the button, and the letter is underlined in the rendered text. Use two ampersands (*&&*) to render a literal ampersand. ### Color Text color is picked per state from the SFTBUTTON_CONTROL color fields. SFT_TEXT.colorFg can override the per-state color when set; leave it at [SFT_NOCOLOR](https://softelvdm.com/Documentation/SftPicture2/Topic/def_sft_nocolor) to use the per-state color from SFTBUTTON_CONTROL. If both are [SFTBUTTON_NOCOLOR](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_nocolor), the control falls back to the system default (COLOR_BTNTEXT) or, in [dark mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode) / [high contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast), the appropriate palette color. ### Font If the SFT_TEXT.hFont is NULL, the control renders text in the font attached to the button's HWND (set with WM_SETFONT). This is the normal Windows convention - setting the dialog's font once through WM_SETFONT propagates to all SftButton controls in the dialog. When using a caller-supplied font, the font is *not* automatically scaled on [DPI](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dpi) changes - the application is responsible for sending WM_SETFONT with a font sized for the new DPI when [SFTBUTTONN_DPI_CHANGED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) fires. See Per-Monitor DPI and Scaling. ### Alignment SFT_TEXT carries horizontal and vertical alignment fields (*align* and *valign*, plus a *flag* field that accepts standard DT_* drawing flags). Horizontal options are left, right, and center; vertical options are top, bottom, and center. Multi-line text uses the same alignment for every line. ### Theme When themes are active (*nUseThemes* is [SFTBUTTON_THEME_YES](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_theme)), Windows chooses the text color; caller-supplied *colorFg* is ignored. To keep theme-drawn border and background but override the text color and font, use *nUseThemes* SFTBUTTON_THEME_YES_NOTEXT instead. Themes are automatically suppressed when dark mode or high contrast is active. See [Using Themes](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_using_themes), Dark Mode and High Contrast. ### Querying access keys [QueryChar](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_querychar) tests whether a given character would activate the button as its access key. Use it from a custom keyboard-accelerator dispatcher to find the SftButton that should receive a given Alt-key combination. ## Colors and Gradients *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients* SftButton supports solid and two-color gradient backgrounds for every rendering state. Colors are specified per state through the [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) structure. ### Per-state background colors | State | Solid | Gradient (start, end) | | --- | --- | --- | | Normal | *colorBg* | *colorBgStart*, *colorBgEnd* | | [Hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover) | *colorBgHover* | *colorBgHoverStart*, *colorBgHoverEnd* | | Focus (button has keyboard focus) | *colorBgFocus* | *colorBgFocusStart*, *colorBgFocusEnd* | | Pressed | *colorBgPressed* | - | ### Solid vs gradient If both gradient endpoints (*colorBgStart* / *colorBgEnd*, etc.) are valid colors, the background is rendered as a gradient between them and the solid color is ignored. If either endpoint is [SFTBUTTON_NOCOLOR](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_nocolor), the solid color is used instead. *nFillOrientation* selects gradient direction: [SFT_ORIENTATION_HORZ](https://softelvdm.com/Documentation/SftPicture2/Topic/def_sft_orientation) (left to right) or SFT_ORIENTATION_VERT (top to bottom, default). Any color field can be set to SFTBUTTON_NOCOLOR to request "transparent" / "system default" behavior - the control uses the appropriate system or palette color. ### Foreground colors *colorFg* is the [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) color for the normal and hover states. *colorFgPressed* replaces it when the button is pressed; *colorFgGrayed* replaces it when the button is disabled. *colorFgDownArrow* is the dropdown-arrow color (or SFTBUTTON_NOCOLOR for the system default). See Text and Fonts. ### Border and 3D edge colors *colorDarkEdge*, *colorLightEdge*, *colorShadowEdge* and *colorWhiteEdge* control the four facets of the 3D edge that [SFTBUTTON_BORDER_STANDARD](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_borderstyle) draws. Each field can be SFTBUTTON_NOCOLOR to use the system default. See [Borders](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_borders). ### Outside background *colorBgOutside* is the color of the area surrounding the button rectangle when the button is smaller than its window (or has been auto-sized). It is rarely set explicitly; the default of SFTBUTTON_NOCOLOR uses the parent's background. ### Theme, dark mode, high contrast When themes are active (*nUseThemes* is [SFTBUTTON_THEME_YES](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_theme)), Windows paints the background and border; caller-supplied background colors are ignored. When [dark mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode) is active, caller colors are honored - the application's chosen colors still win over the dark palette default. When [Windows High Contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast) is active, caller colors are ignored and the user's contrast theme wins (see High Contrast). Accent colors that work in both light and dark modes use channels in the RGB 30-210 range; pure-channel values (0 or 255) often read poorly in one mode or the other. ## Borders *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_borders* The button's border is selected through the *nBorderStyle* field on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control). Three styles are supported: | Style | Appearance | | --- | --- | | [SFTBUTTON_BORDER_THIN](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_borderstyle) (0) | A thin single-pixel border. Useful for dense toolbars and flat designs. | | SFTBUTTON_BORDER_STANDARD (1) | The classic raised-edge 3D border. This is the default. | | SFTBUTTON_BORDER_PIXEL1 (2) | A single-pixel flat border drawn with the appropriate edge color. Useful for strongly colored buttons where the 3D edge would clash. | By default, the border is drawn only when the button is in the pressed, [hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover) or focus state. Set *fBorderAlways* to TRUE to draw the border in every state. ### 3D edge colors *colorDarkEdge*, *colorLightEdge*, *colorShadowEdge* and *colorWhiteEdge* on SFTBUTTON_CONTROL control the four facets of the 3D edge that SFTBUTTON_BORDER_STANDARD draws. Each field can be [SFTBUTTON_NOCOLOR](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_nocolor) to use the appropriate system color (COLOR_3DDKSHADOW, COLOR_3DLIGHT, COLOR_3DSHADOW, COLOR_3DHIGHLIGHT). See [Colors and Gradients](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients). ### Theme When [Windows themes](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_using_themes) are active (*nUseThemes* [SFTBUTTON_THEME_YES](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_theme)), the theme paints the border; caller-supplied edge colors are ignored. Themes are automatically suppressed when [dark mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode) or [high contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast) is active. See Using Themes. ### Default-button outline A button marked as the dialog default (*fDefault* TRUE) renders an extra outline around the border. Set *fHideDefault* to TRUE to suppress that outline if the application supplies its own default-button visual. ## Dropdown Button *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown* A SftButton can display an attached dropdown arrow on its right edge. Set *fShowDropDown* to TRUE on the [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) structure to show the arrow. The arrow is drawn on top of the background, in a sidebar separated from the main button area. ### Styles The arrow shape and the sidebar width are controlled by *nDropDownStyle*: | Style | Description | | --- | --- | | [SFTBUTTON_DROPDOWNSTYLE_STANDARD](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_dropdownstyle) (0) | A standard width sidebar and arrow glyph. This is the default. | | SFTBUTTON_DROPDOWNSTYLE_NARROW1 / _NARROW2 / _NARROW3 | Progressively narrower sidebars. Useful for tool buttons where horizontal space is tight. | | SFTBUTTON_DROPDOWNSTYLE_WIDE1 | A wider sidebar. Useful for prominent dropdown affordances. | ### Notifications Clicks on the dropdown arrow generate separate notifications so the application can distinguish between "invoke the primary button action" and "open the dropdown menu": | | | | --- | --- | | [BN_CLICKED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) (SFTBUTTONN_CLICK) | The user clicked on the main button area. | | SFTBUTTONN_DROPDOWNCLICK | The user clicked on the dropdown arrow. | | SFTBUTTONN_DBLCLICK | The user double-clicked on the main button area. | | SFTBUTTONN_DROPDOWNDBLCLICK | The user double-clicked on the dropdown arrow. | A typical WM_COMMAND handler dispatches the dropdown notification by showing a popup menu; the primary BN_CLICKED handler invokes the button's default action. The application can also simulate a dropdown click programmatically with [SftButton_DoClickDropDown](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_doclickdropdown). ### Accessibility When *fShowDropDown* is TRUE, the [UIA](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_accessibility) control type exposed to screen readers becomes **SplitButton** (rather than plain Button). Narrator / NVDA / JAWS users can then invoke the primary action and the dropdown arrow as separate targets. See Accessibility (Screen Readers). ## Toggle (Check Box) Behavior *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_toggle* A SftButton with *fToggle* set to TRUE acts as a two-state button: each click flips the button between pressed and not-pressed, rather than returning to normal when the mouse button is released. The current state is held in the *fPressed* field. ### Visual feedback In the pressed state, the button renders using its Pressed-state images (*Picture1Pressed*, *Picture2Pressed*, *PictureBGPressed*), the *colorBgPressed* background color and the *colorFgPressed* [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) color. Unlike a momentary press, the Pressed visual stays on the button until the user clicks again. ### Programmatic control The application can query and set the toggle state by calling [SftButton_GetControlInfo](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_getcontrolinfo) / [SftButton_SetControlInfo](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setcontrolinfo) and reading / writing *fPressed*. [SftButton_DoClick](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_doclick) synthesizes a click and flips the state. ### Groups SftButton does not implement intrinsic radio-button groups. Applications that want single-select radio behavior across multiple toggle buttons handle [BN_CLICKED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) on each button and reset the other buttons' *fPressed* to FALSE through SftButton_SetControlInfo. ### Accessibility When *fToggle* is TRUE, the [UIA](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_accessibility) Toggle pattern is exposed to screen readers. The pressed state is announced as "pressed" / "not pressed". See Accessibility (Screen Readers). ## Auto-Sizing *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_autosize* SftButton can automatically resize itself to fit its [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) and images, re-anchoring to one of nine reference points on its original bounding rectangle. Set *iAutoSize* on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) to opt in. ### Anchor values | Value | Anchor point | Button grows toward | | --- | --- | --- | | [SFTBUTTON_AUTOSIZE_NONE](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_autosize) (0) | - (disabled) | - | | SFTBUTTON_AUTOSIZE_TOPLEFT | Top-left corner | Right and down | | SFTBUTTON_AUTOSIZE_TOPRIGHT | Top-right corner | Left and down | | SFTBUTTON_AUTOSIZE_BOTTOMLEFT | Bottom-left corner | Right and up | | SFTBUTTON_AUTOSIZE_BOTTOMRIGHT | Bottom-right corner | Left and up | | SFTBUTTON_AUTOSIZE_TOPCENTER | Top edge, horizontally centered | Down, growing symmetrically from center | | SFTBUTTON_AUTOSIZE_BOTTOMCENTER | Bottom edge, horizontally centered | Up, growing symmetrically from center | | SFTBUTTON_AUTOSIZE_LEFTCENTER | Left edge, vertically centered | Right, growing symmetrically from center | | SFTBUTTON_AUTOSIZE_RIGHTCENTER | Right edge, vertically centered | Left, growing symmetrically from center | | SFTBUTTON_AUTOSIZE_CENTER | Original center | Symmetrically in all directions | The original bounding rectangle is recorded at the moment SFTBUTTON_AUTOSIZE is first set. Subsequent text, image and border changes recompute the optimal size and reposition the button relative to the recorded anchor. ### SftButton_CalcOptimalSize [SftButton_CalcOptimalSize](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_calcoptimalsize) returns the optimal width and height without actually resizing the button. Useful for laying out the parent dialog before creating the button, or for computing the size of a future button given candidate text / image content. ### Interaction with parent-driven resize If the parent repositions the button (MoveWindow / SetWindowPos), the anchor is updated to match the new rectangle. ## Click Regions *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_click_regions* SftButton supports four click-region modes through *iClickStyle* on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control). The click region is the area inside the button that generates a [BN_CLICKED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) notification when the user presses the primary mouse button. | Style | Click region | | --- | --- | | [SFTBUTTON_CLICKSTYLE_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_clickstyle) (0) | The entire button rectangle. Default. Matches the behavior of a standard Windows push button. | | SFTBUTTON_CLICKSTYLE_EXACT (1) | Only the area actually occupied by [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) and images. Clicking on the background padding around the text does not count. | | SFTBUTTON_CLICKSTYLE_IMAGESONLY (2) | Only pixels covered by an image layer (*Picture1* / *Picture2* / *PictureBG* and their per-state variants) generate clicks. | | SFTBUTTON_CLICKSTYLE_TEXTONLY (3) | Only pixels covered by text generate clicks. | Click regions let you implement buttons whose interactive area differs from their visual area - for example a button that renders a background image across its full rectangle but only activates on the foreground icon. The [dropdown arrow](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown) (if enabled) has its own fixed click region and is unaffected by *iClickStyle*. ### Hover regions [Hover detection](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover) has a parallel setting, *iHoverStyle*. The hover region can be independent of the click region. See Hover Detection. ## Hover Detection *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover* A SftButton tracks hover state separately from mouse-over. The hover state controls which per-state images and [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients) the control renders, and generates [SFTBUTTONN_HOVERON](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) and SFTBUTTONN_HOVEROFF notifications when it flips. ### Hover style *iHoverStyle* on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) selects the hover-detection region: | Style | Hover region | | --- | --- | | [SFTBUTTON_HOVERSTYLE_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_hoverstyle) (0) | Hover turns on when the mouse enters the button's client rectangle and off when it leaves. Default. | | SFTBUTTON_HOVERSTYLE_EXACT (1) | Hover turns on only when the mouse is over a pixel that is actually rendered ([text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) or image). Moving the mouse to background padding within the button rectangle turns hover off. | ### Notifications SFTBUTTONN_HOVERON is sent when hover starts and SFTBUTTONN_HOVEROFF when it ends. Applications can use these for rollover effects outside the button itself - for example updating a status-bar description or pre-loading a related resource. ### Relationship to click regions Hover style and click style are independent. A button can have click style [SFTBUTTON_CLICKSTYLE_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_clickstyle) (clicks anywhere) but hover style SFTBUTTON_HOVERSTYLE_EXACT (rollover highlighting only on visible content). ## Press Animation *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_bouncing* The "bounce" animation is a short visual offset applied when the user presses the button - the button content shifts a few pixels down and to the right, giving a tactile feedback cue. The effect is purely visual; no additional click notifications are generated. ### Per-control override *iBounce* on [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) controls the animation per button: | Value | Behavior | | --- | --- | | [SFTBUTTON_BOUNCE_DEFAULT](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_bounce) (0) | Follow the application default (which is currently on). Use this value when you don't need to override. | | SFTBUTTON_BOUNCE_YES (1) | Always animate on press, regardless of the application default. | | SFTBUTTON_BOUNCE_NO (2) | Never animate, regardless of the application default. Useful for rapid-fire buttons (tool palette items, step buttons) where the animation would feel sluggish. | ### Interaction with theme When themes are active (*nUseThemes* is [SFTBUTTON_THEME_YES](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_theme)), Windows draws the pressed-state visual and the bounce animation is suppressed - the theme's own press animation is used instead. ### DPI The pixel offset of the bounce animation is scaled automatically by monitor [DPI](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dpi). No caller action is needed. See Per-Monitor DPI and Scaling. ## Bitmap Transparency *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_bitmap_transparency* SftButton/DLL automatically uses bitmap transparency for all bitmaps used in a button control. When a bitmap is displayed, the background can show through portions of the bitmap. SftButton/DLL accomplishes this by dynamically modifying a copy of the bitmap to adjust for the background. 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. 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 or other images that can be represented by a [SFT_PICTURE](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_picture) structure. Bitmap transparency for bitmaps is fully automatic and cannot be turned off. ## GDI+ *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus* The button control uses GDI+ for additional image features not otherwise available: - Image support for PNG, TIFF, JPEG, GIF, Exif, EMF+, EMF (GDI+ images) with full support for alpha-blended (translucent and semi-transparent) images GDI+ ships with all supported Windows versions (Windows 10 and above), so these features are always available. ### Loading GDI+ images SftButton provides four helpers that wrap GDI+ image creation and disposal so the application does not have to call *GdiplusStartup* or work with *Gdiplus::Image* directly. Each loader returns a *Gdiplus::Image** as an opaque *LPVOID* that is plugged into a [SFT_PICTURE](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_picture) slot of type [SFT_PICTURE_GDIPLUS](https://softelvdm.com/Documentation/SftPicture2/Topic/def_sft_picture_types) (typically through *[Sft_SetPictureGDIPlusImage](https://softelvdm.com/Documentation/SftPicture2/Topic/function_setpicturegdiplusimage)*). | Function | Description | | --- | --- | | [LoadGDIPlusImageFromResource](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_loadgdiplusimage) | Load a PNG / TIFF / JPEG / GIF / EMF image from an embedded application resource. | | LoadGDIPlusImageFromFile | Load the same image formats from a file on disk. | | [FreeGDIPlusImageLoadedFromResource](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_freegdiplusimage) | Free a pointer returned by LoadGDIPlusImageFromResource. | | FreeGDIPlusImageLoadedFromFile | Free a pointer returned by LoadGDIPlusImageFromFile. | The loader and the matching free routine must always be paired - resource-loaded images go through *FreeGDIPlusImageLoadedFromResource*, file-loaded images through *FreeGDIPlusImageLoadedFromFile*. ## Using Themes *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_using_themes* Windows themes can be selected by the user using the Settings app or the Control Panel. If a theme is selected, the display of user interface controls, such as SftButton/DLL, adapts to the current display theme. The button control renders in one of three theme modes (see *[SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control).nUseThemes*): | | | | --- | --- | | [SFTBUTTON_THEME_NO](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_theme) (0) | Themes are not honored; the control renders using its built-in style, [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients), gradients and images. | | SFTBUTTON_THEME_YES (1) | Themes are fully honored. Windows renders the button background and border; the control renders its images and [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) on top. | | SFTBUTTON_THEME_YES_NOTEXT (2) | Themes are honored for the button background and border only. The application's text color and font are used as specified instead of the theme's. | SftButton/DLL 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. Keep in mind that numerous button definitions, particularly relating to per-state colors, gradients and [borders](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_borders), have no effect when themes are active. Windows themes are automatically suppressed when [Dark Mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode) or [Windows High Contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast) is active on the button control. See Dark Mode and High Contrast for details on the alternative rendering paths used in each case. ## Dark Mode *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode* SftButton/DLL 3.0 supports dark mode. The default for new buttons is [SFTBUTTON_DARKMODE_OFF](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_darkmode) (always light) to preserve visual back-compatibility for applications written before dark mode existed. Applications that want their buttons to follow the Windows 10 "Choose your mode" [accessibility](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_accessibility) setting should call [SetDarkMode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setdarkmode) with SFTBUTTON_DARKMODE_AUTO once at control creation, or maintain their own Light / Dark [toggle](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_toggle) and switch each button to ON / OFF as the toggle changes. What changes in dark mode: the button background, [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text), border, focus ring, [dropdown arrow](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown) and [hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover)/pressed overlays all switch to dark-palette [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients). Theme-driven chrome is suppressed while dark mode is active so that the button matches the control's dark palette instead of the system's light-themed push-button style. The button control's dark mode setting has three values (see SetDarkMode): | | | | --- | --- | | **OFF** (default) | Always use the light palette, regardless of the Windows setting. Preserves visual back-compatibility for applications written before dark mode existed. | | **ON** | 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. | | **AUTO** | Follow the Windows "Choose your mode" setting. The control re-renders when the system setting flips and sends [SFTBUTTONN_DARKMODE_CHANGED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) to the parent window. | SFTBUTTONN_DARKMODE_CHANGED is sent to the parent window each time the active dark mode state flips (AUTO mode only) so the application can repaint its own chrome around the button control. [IsDarkModeActive](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_isdarkmodeactive) reports the current state at any time. Caller-supplied color overrides (per-state background colors, gradient start/end colors, text colors, border colors) are still honored in dark mode - the control does *not* override application-chosen colors. If you need specific buttons to stand out in 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). [Windows themes](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_using_themes) are suppressed while dark mode is active. The button's background, border and dropdown arrow fall back to the control's built-in dark-aware GDI rendering path so they match the dark palette instead of the system's light-themed button style. ### Host dialog integration The button control follows the dark mode setting at the **control** level. The hosting dialog itself - title bar, dialog background, static labels, group boxes, edits and any standard Win32 controls placed alongside the button - also needs to be wired into dark mode for the dialog to render coherently. The shared [SftDarkMode](https://softelvdm.com/Documentation/SftDarkMode/Topic/1_main) helper provides that integration: a single header (SftDarkMode.h) used by every Softel vdm DLL product that handles dialog title bars, WM_CTLCOLOR* responses, the Windows "Choose your mode" toggle, and dark NC scrollbars on standard controls. A typical adoption is four call sites: [SftDarkMode_Init](https://softelvdm.com/Documentation/SftDarkMode/Topic/function_init) at process startup, [SftDarkMode_ApplyToDialog](https://softelvdm.com/Documentation/SftDarkMode/Topic/function_applytodialog) from each WM_INITDIALOG, [SftDarkMode_HandleDialogMessage](https://softelvdm.com/Documentation/SftDarkMode/Topic/function_handledialogmessage) routed from each dialog procedure, and an optional [SftDarkMode_SetActive](https://softelvdm.com/Documentation/SftDarkMode/Topic/function_setactive) when the application exposes its own Light / Dark toggle. Platform note: Dark mode requires Windows 10 or later. On earlier platforms the setting is stored but has no visual effect. ## High Contrast *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast* Windows High Contrast is an [accessibility](https://softelvdm.com/Documentation/SftButton%20DLL%203%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](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients). SftButton/DLL 3.0 follows this rule automatically. When Windows High Contrast is active, the button control: - renders backgrounds in *COLOR_WINDOW* (or *COLOR_3DFACE* for pressed state), [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) in *COLOR_WINDOWTEXT*, focus ring in *COLOR_HIGHLIGHT*, and [borders](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_borders) in *COLOR_BTNSHADOW* / *COLOR_BTNHIGHLIGHT*, - ignores caller-supplied color overrides (per-state background, gradient start/end, text color, border color) on the default render path - the user's contrast theme wins, - suppresses [Windows themes](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_using_themes). The button background and border fall back to a non-themed GDI path that honors system colors directly. The button control's high contrast setting has three values (see [SetHighContrastMode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_sethighcontrastmode)): | | | | --- | --- | | **AUTO** (default) | Follow the Windows High Contrast setting. The control re-renders when the setting flips. | | **ON** | 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. | | **OFF** | 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. | [SFTBUTTONN_HIGHCONTRAST_CHANGED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) is sent to the parent window each time the active state flips (AUTO mode only) so the application can repaint its own chrome to match. [IsHighContrastActive](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_ishighcontrastactive) reports the current state at any time. [Dark mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%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. ## Accessibility (Screen Readers) *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_accessibility* SftButton/DLL 3.0 ships with 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 SftButton controls without the hosting application doing any work. No opt-in, no code change, no separate build. What the screen reader sees: | | | | --- | --- | | Control type | **Button**. For buttons with a [dropdown arrow](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown) (*fShowDropDown* set), the control type becomes **SplitButton** so the user hears "split button" and can invoke the primary action and the dropdown arrow independently. | | Name | The button's [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text) (with the ampersand accelerator prefix stripped for speech). | | [Toggle](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_toggle) state | For toggle buttons (*fToggle* set), the current pressed state is exposed through the Toggle pattern. The screen reader announces "pressed" / "not pressed". | | Help text | Any tooltip the application has set on the control is routed through the UIA *HelpText* property. | | Patterns implemented | Invoke, Toggle (for toggle buttons), ExpandCollapse (for split buttons, for the dropdown arrow), Value (read-only - the button text). | Event notifications raised automatically: invoke, toggle-state changed, keyboard focus changed. There is nothing to turn on. 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. The main thing the application controls is the button's text - screen readers read it first, so a generic "OK" tells the user less than "Save and close this document". [Dark mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode) and [Windows High Contrast](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast) are independent accessibility settings. SftButton honors both automatically (see [SetDarkMode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setdarkmode) and [SetHighContrastMode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_sethighcontrastmode)). ## Per-Monitor DPI and Scaling *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dpi* SftButton/DLL 3.0 is fully Per-Monitor v2 DPI-aware. A button control hosted on a Per-Monitor v2 aware top-level window will re-render 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 and, by default, also scales caller-supplied images and pixel dimensions for the current monitor; two flags let the caller take that scaling back over if needed. ### Host setup The host application must declare Per-Monitor v2 DPI awareness. This is the single most common reason SftButton/DLL 3.0 applications do not re-render correctly when moved between monitors of different DPI. Without a PMv2 declaration, Windows silently keeps the process in System-aware mode: the DPI is fixed for the process lifetime, SftButton does not observe DPI changes, [SFTBUTTONN_DPI_CHANGED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) is never raised, and high-DPI monitors render at System-DPI sizes stretched by Windows. Visual Studio's default *app.manifest* does **not** declare PMv2 awareness - the developer must opt in explicitly. Two approaches - pick one: #### Application manifest (recommended) Add a ** / ** element to the application manifest. Both elements are usually included for back-compatibility with older Windows 10 builds: ``` PerMonitorV2 True/PM ``` In a Visual Studio C++ project, set *Project Properties -> Manifest Tool -> Input and Output -> Additional Manifest Files* to the .manifest file above, or edit the auto-generated manifest directly. In a C# / .NET project, check *Application -> DPI awareness* and select *Per Monitor V2*. #### Runtime API Alternatively, call SetProcessDpiAwarenessContext at process startup, before any window is created: ``` SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); ``` Caveat: This call must run before the first window (including hidden startup dialogs or splash screens) is created. If a window has already been created, Windows rejects the call and the process remains in whichever mode the manifest specified - which, with the Visual Studio default, is System-aware. #### Verifying the declaration worked Quick check at runtime: GetDpiForWindow on the button control returns the current monitor's DPI - 96 at 100%, 120 at 125%, 144 at 150%, 192 at 200%. If the returned value never changes as you drag the window between monitors with different scale factors, the host is not in PMv2 mode. ### What scales automatically When the host is Per-Monitor v2 aware, the button control scales these metrics itself on every DPI change without any caller involvement: - button border widths, - focus-ring inset, - dropdown-arrow width and glyph size, - internal padding between the border, images and [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text), - the [bounce](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_bouncing)-animation pixel offset, - the control-owned [dropdown arrow](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown) glyph. ### What the caller controls Two independent flags let the caller choose whether caller-supplied pixel metrics and caller-supplied images also scale with DPI. Both default to **STRETCH** - on a Per-Monitor v2 host, a fresh button automatically scales its images and pixel metrics to the current monitor without any opt-in. Applications that ship multiple image sizes, pre-scaled pixel layouts, or otherwise want full control over the rendered size can opt out by switching either flag to ASIS. | Flag | Covers | STRETCH (default) | ASIS | | --- | --- | --- | --- | | [SetImageScaling](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setimagescaling) | Every image the control draws: per-state foreground pictures (*Picture1* / *Picture1Hover* / *Picture1Pressed* / *Picture1Disabled* and the matching *Picture2**), per-state background pictures (*PictureBG**). | Images are scaled by *currentDPI / 96*. Bitmaps use *HALFTONE* stretch; [GDI+](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus) images use *InterpolationModeHighQualityBicubic*. | Images are drawn at their native pixel size. Bitmaps supplied at 96 DPI look physically smaller on a high-DPI monitor. | | [SetPixelScaling](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setpixelscaling) | Caller-supplied pixel dimensions on the [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) structure (any pixel-valued offsets, insets and forced sizes the application sets). | Values are interpreted as 96-DPI reference pixels. A value of 20 is 20 pixels at 100%, 30 pixels at 150%, 40 pixels at 200%. Storage and getters always return caller-reference units so serialized configurations stay portable. | Values are used verbatim in physical screen pixels. | ### Decision guide | Goal | Setting | | --- | --- | | "I want crisp images on high-DPI monitors without code changes" | Default behavior - no call needed. SetImageScaling stays at STRETCH. | | "My existing application already ships pre-scaled images and wants the control to draw them as-is" | Call SetImageScaling with [SFTBUTTON_IMAGESCALING_ASIS](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_imagescaling) once at control creation. | | "Pixel offsets stored in a SFTBUTTON_CONTROL structure should stay physically the same size as the user moves between monitors" | Default behavior - no call needed. SetPixelScaling stays at STRETCH. | | "My serialized / saved button configurations must stay portable across DPI" | Default behavior - no call needed. Storage stays in 96-DPI reference pixels regardless of monitor. | | "My pixel offsets are already pre-scaled for the runtime monitor and should be used verbatim" | Call SetPixelScaling with [SFTBUTTON_PIXELSCALING_ASIS](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_pixelscaling) once at control creation. | ### Caller responsibilities on DPI change When the control's monitor DPI changes, SftButton raises **SFTBUTTONN_DPI_CHANGED** to the parent window. The application should: - re-send WM_SETFONT with a font sized for the new DPI (SftButton does not own the application's font), - if SetImageScaling is STRETCH (default), no action needed - the control scales existing images automatically, - if SetImageScaling is ASIS and the caller wants crisp images, re-register per-state [SFT_PICTURE](https://softelvdm.com/Documentation/SftPicture2/Topic/struct_sft_picture) images at the new physical size, - if SetPixelScaling is STRETCH (default), no action needed - the control scales stored values automatically, - if SetPixelScaling is ASIS, re-apply caller-supplied pixel dimensions scaled for the new DPI. Platform note: Per-Monitor v2 DPI awareness requires Windows 10 version 1703 or later. On older platforms the host process runs in System-aware or Unaware mode and DPI is effectively fixed for the process lifetime - SftButton still renders correctly but does not fire SFTBUTTONN_DPI_CHANGED. ## Demo Application *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_demo_application* During the installation of SftButton/DLL, an icon for the demo application "Demo" is installed in the program group *SftButton DLL 3.0*. This demo application shows some of the features available in SftButton/DLL. It is also used to launch the [SftButton/DLL Wizard](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_wizard), run the sample applications included with the product and view the online help. ![Demo Application](https://softelvdm.com/Vault/Softelvdm.com/docx/SftButton%20DLL%203.0/image/demo.png) > All sample programs and complete sample source code can be found in the directory "\Program Files (x86)\Softelvdm\SftButton DLL 3.0\Samples". Each sample is installed in its own subdirectory. All [samples](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_samples) are supplied with a precompiled executable (Exe) and an entry is added to the *SftButton DLL 3.0* program group for each sample. ## Samples *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_samples* SftButton/DLL includes sample code for C and C++/MFC. The samples listed in the following table can be found in the folder "\Program Files (x86)\Softelvdm\SftButton DLL 3.0\Samples". These samples are also referenced throughout the documentation. ### C | C Sample | Description | | --- | --- | | [Simple Sample](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/sample_c_simple) | Illustrates basic button creation in a dialog, including theme and dark-mode configuration and click-notification handling. | ### C++/MFC | C++/MFC Sample | Description | | --- | --- | | [Simple Sample](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/sample_mfc_simple) | Illustrates dialog-based button hosting through [CSftButton](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_csftbutton) and DDX_Control, [GDI+](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus) image loading and lifecycle, drop-down click handling, and runtime dark-mode and theme toggles. | ## Simple Sample (C) *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/sample_c_simple* This sample illustrates basic SftButton creation in a dialog. It covers registering the button window class, placing a button from a dialog resource, configuring theme and dark-mode behavior, and handling [BN_CLICKED](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) notifications. The source code is located at C:\Program Files (x86)\Softelvdm\SftButton DLL 3.0\Samples\C\Simple\Simple.c or C:\Program Files\Softelvdm\SftButton DLL 3.0\Samples\C\Simple\Simple.c (on 32-bit Windows versions). [Full sample source — Simple Sample (C) (192 lines) →](https://softelvdm.com/Vault/Softelvdm.com/llms/SftButton-DLL-3.0-samples.txt) ## Simple Sample (C++/MFC) *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/sample_mfc_simple* This sample illustrates SftButton creation and configuration from a C++/MFC application. It covers process-wide registration, attaching [CSftButton](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_csftbutton) instances to dialog template controls through DDX_Control, configuring buttons through [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control), loading and freeing [GDI+](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus) images for the Picture1 / Picture2 slots, runtime dark-mode and theme toggles, and routing dark-mode painting through the *[SftDarkMode](https://softelvdm.com/Documentation/SftDarkMode/Topic/1_main)* helper. The dialog hosts three SftButton controls and two checkboxes: - **Button 1** - [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text)-only button, dark-mode AUTO. Demonstrates the minimal configuration path: [GetControlInfo](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_getcontrolinfo) / change one field / [SetControlInfo](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setcontrolinfo). - **Button 2** - dual-image button (Picture1 + Picture2) loaded from PNG files via [SftButton_LoadGDIPlusImageFromFile](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_loadgdiplusimage). Demonstrates GDI+ image lifecycle: loaded in OnInitDialog, freed in OnDestroy with [SftButton_FreeGDIPlusImageLoadedFromFile](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_freegdiplusimage). - **Button 3** - drop-down button (*fShowDropDown = TRUE*). Demonstrates handling [SFTBUTTONN_DROPDOWNCLICK](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) in addition to BN_CLICKED through ON_CONTROL. - **Use Themes** checkbox - toggles *nUseThemes* between [SFTBUTTON_THEME_YES](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_theme) and SFTBUTTON_THEME_NO across all three buttons. - **[Dark Mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode)** checkbox - toggles [SetDarkMode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setdarkmode) between [SFTBUTTON_DARKMODE_ON](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_darkmode) and SFTBUTTON_DARKMODE_OFF on all three buttons and re-applies SftDarkMode to the dialog. The source code is located at C:\Program Files (x86)\Softelvdm\SftButton DLL 3.0\Samples\MFC\Simple\ (or C:\Program Files\Softelvdm\SftButton DLL 3.0\Samples\MFC\Simple\ on 32-bit Windows versions). ### Simple.cpp - CWinApp initialization The CWinApp-derived class registers the SftButton window class in InitInstance and unregisters it in ExitInstance. [SftDarkMode_Init](https://softelvdm.com/Documentation/SftDarkMode/Topic/function_init) runs alongside so dark-mode painting is available before the main dialog is shown. [Full sample source — Simple Sample (C++/MFC) — Simple.cpp - CWinApp initialization (41 lines) →](https://softelvdm.com/Vault/Softelvdm.com/llms/SftButton-DLL-3.0-samples.txt) ### Maindlg.h - dialog class CMainDlg embeds three CSftButton members - one per dialog control - and two LPVOID slots for the GDI+ images that Button 2 displays. DDX_Control attaches the embedded CSftButton instances to the dialog-template controls in DoDataExchange. [Full sample source — Simple Sample (C++/MFC) — Maindlg.h - dialog class (35 lines) →](https://softelvdm.com/Vault/Softelvdm.com/llms/SftButton-DLL-3.0-samples.txt) ### Maindlg.cpp - dialog implementation OnInitDialog configures each button through GetControlInfo / SetControlInfo, loads the GDI+ images for Button 2, and applies dark mode to the dialog itself with [SftDarkMode_ApplyToDialog](https://softelvdm.com/Documentation/SftDarkMode/Topic/function_applytodialog). ON_BN_CLICKED and ON_CONTROL entries in the message map dispatch click and drop-down notifications. OnDestroy frees the GDI+ images with SftButton_FreeGDIPlusImageLoadedFromFile after the controls have stopped using them. WindowProc forwards messages to [SftDarkMode_HandleDialogMessage](https://softelvdm.com/Documentation/SftDarkMode/Topic/function_handledialogmessage) so the dialog repaints correctly under dark mode. OnSettingChange forwards WM_SETTINGCHANGE / ImmersiveColorSet to each button so AUTO-mode buttons re-render when the user flips the Windows "Choose your mode" setting at runtime. [Full sample source — Simple Sample (C++/MFC) — Maindlg.cpp - dialog implementation (173 lines) →](https://softelvdm.com/Vault/Softelvdm.com/llms/SftButton-DLL-3.0-samples.txt) See Also [Using C++/MFC](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_usingcpp) | [MFC and Notifications](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_notificationsmfc) | Dark Mode | GDI+ ## SftButton/DLL Wizard *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_wizard* During the installation of SftButton/DLL, an icon for the application "Wizard" is installed in the program group *SftButton DLL 3.0*. This application can be used to generate most of the source code needed to create and initialize a button control in a dialog or a window. It honors most SftButton/DLL attributes and should be used at design-time to build the necessary button control initialization code. The SftButton/DLL Wizard application is used to design a button control look. All control attributes - including the button's images - can be manipulated in the Wizard; the Wizard provides a set of sample images to choose from, and of course an application can freely define its own pictures at run time. You design the desired look on the design tabs (on the right hand side) and immediately see it reflected in the sample button control (on the left side). Once the desired look has been achieved, the run-time source code used to create and initialize the button control can be generated for C and C++/MFC by clicking on the corresponding tab. The generated source code contains step by step instructions on how to incorporate it into an application. ## SftButton/DLL Wizard Help *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/idh_wizardhelp* ### SftButton/DLL Wizard The [SftButton/DLL Wizard](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_wizard) is used to define a new button control look or to edit an existing look. The definitions are saved in button definition files with the extension *.BTN. Visit each tab page (on the right hand side) and set the desired properties. These will immediately be reflected in the sample button control (on the left side). The most important tab is the **"Class Info"** tab. Define the C or C++ information as it is used in your application. Once you have filled in this information correctly, click on the **C** or **C++/MFC** tab. The source code displayed can now be copied into your application. Make sure to read the step-by-step instructions in the source code. This source code usually requires only minimal changes to work in your application. You will have to provide your own pictures and button [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text), but the other initialization information can be used as-is. Once you have defined your button control settings, you can save the BTN file (for later editing). If you make modifications to your button control definition, you will of course have to again copy the generated source code (or portions). ## SftButton/DLL Wizard - Design Pages *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/idh_control_page* The [SftButton/DLL Wizard](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_wizard) uses four design tab pages - **Style**, **[Colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients)**, **Class Info** and **Events** - to define the look and behavior of a button control. Settings made on these pages are reflected immediately in the sample button control. When the desired look has been achieved, the C and C++/MFC tabs produce the source code needed to create and initialize the button control in an application. ### Style The Style page controls the overall appearance and behavior of the button control. The *preview mode* radio buttons at the top of the page (**Normal Mode**, **[Dark Mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_darkmode)**, **[High Contrast Mode](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_highcontrast)**) affect only how the sample button is rendered in the Sample window - they are not part of the generated source code. The remaining settings are reflected in the generated code. | Label | Description | | --- | --- | | Theme | Selects how the button is themed - *Use theme* (full visual theme), *Theme except [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text)* (themed background with the button's own text rendering) or *No theme*. | | Support Dark Mode | When checked, the button tracks the Windows dark-mode setting (AUTO). When unchecked, dark mode support is off. | | Support High Contrast Mode | When checked, the button tracks the Windows high-contrast setting (AUTO). When unchecked, high-contrast support is off. | | Caption (use && for access key) | The text displayed on the button. Use && to designate an access key. | | Horizontal alignment / Vertical alignment (Text) | Alignment of the button text within the control. | | Font... | Opens a font picker for the button text font. | | Border style | The button's border style - *Standard*, *Thin* or *Single pixel*. | | Always draw border | Always draws the button border, even when the button would otherwise omit it. | | Allow focus | Allows the button to receive the input focus. | | Default button | Styles the button as the default button. | | Hide focus rectangle | Suppresses the focus rectangle on the button. | | Hide default/focus button outlining | Suppresses the default-button / focus outlining drawn around the button. | | [Toggle](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_toggle) | The button toggles its pressed state on each click. | | Initially pressed | The button starts out in the pressed state. | | Follows (pressed while [hover](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_hover)) | The button appears pressed while the mouse hovers over it. | | Drop-down Style | The style of the drop-down arrow area - *Standard*, *Narrow 1*, *Narrow 2*, *Narrow 3* or *Wide 1*. | | Drop-down Toggle / Initially pressed / Follows (pressed while hover) | The toggle, initially-pressed and follows behavior for the drop-down area of the button. | | Show (drop-down) | Shows the drop-down arrow on the button. | | Show on mouse-down click | The drop-down acts on the mouse-down click rather than the mouse-up click. | | Image1/Text/Image2 orientation | Horizontal or vertical layout of the two image layers and the button text. | | Image 1 ... Image 2 (Edit...) | Each image layer (Image 1, Image 2, plus their Hover / Pressed / Disabled variants and the Background variants) can be assigned a sample picture, bitmap, built-in image or color sample using the *Edit...* button. | | Alignment (Image 1, Image 2) | Horizontal and vertical alignment of image layers 1 and 2 within the control. | | AVI transparent | Treats AVI images as transparent. | | No background | The button does not draw its background. | | Hover style | Controls which area of the button is hover-sensitive - *Whole control* or *Exact (picture + text rects)*. | | Click style | Controls which area of the button is click-sensitive - *Whole control*, *Exact (picture + text rects)*, *Images only* or *Text only*. | | [Bounce](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_bouncing) | The press "bounce" animation - *Default (follow theme)*, *Yes* or *No*. | | Auto-repeat (ms) | The auto-repeat interval (in milliseconds) while the button is held pressed; 0 disables auto-repeat. | | [Anchor](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_autosize) (Auto-size) | The anchor used when the button auto-sizes itself - *None*, one of the eight edge/corner anchors, or *Center*. | ### Colors The Colors page assigns the per-state colors used by the button control. Select an area in the **Control area** list (text foreground, backgrounds, edges, gradient base/start/end for the normal, focus and hover states, and so on), then pick a color for it from the **Color** list. Selecting *(Custom)* and clicking the color swatch opens the standard color picker. The **Color** list also shows the name of the currently selected color. | Label | Description | | --- | --- | | Control area | Selects which part of the button control the color picker applies to. | | Color | Selects the color (named color, *(Default)* for the system color, or *(Custom)* for a user-chosen color) for the selected control area, and shows the selected color's name. | | Gradient orientation | The orientation - *Horizontal* or *Vertical* - of the gradient fill (used when both gradient start and end colors are set). | | Reset all to default | Resets every button color to the system default. | ### Class Info Based on the information entered on this page, the generated source code is adjusted to reflect the following settings: | Label | Description | | --- | --- | | Resource ID | Enter the ID used for the button control in a DIALOG resource or as a child window. | | C (HWND variable) | Enter the variable name used to hold the window handle of the button control in a C application. This field is not used for C++ applications. | | C++/MFC ([CSftButton](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_csftbutton) member) | Enter the variable name used for the C++ button control object, as used by the parent window of the button control. | ### Events All notifications generated by the button control are displayed in a list as they occur. Interact with the sample button to populate the list. This is useful for understanding which notifications fire and when. ## C, C++/MFC - Generated Source Code *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/idh_edit_page* The source code generated using the C or C++/MFC tabs can be used to implement a button control in an application. Usually the source code can be used with just minor modifications. By following the comments in this source code, the relevant sections can be copied to your application. Use the *Edit*, *Find* menu command to locate [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text). ## Building Applications *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_buildingapp* This section describes how to prepare an application using the C or C++ programming language to successfully use SftButton/DLL. ### Updating Project Settings #### Include Files In order for #include files to be located in the SftButton/DLL product directory, each project that uses SftButton/DLL must be updated to search the product directory. The default include directory name is \Program Files (x86)\Softelvdm\SftButton DLL 3.0\Include unless changed during installation. Make sure to update all configurations (both Debug and Release). Using the *Project*, *Properties...* menu command, the project's Property Pages are accessed so the #include directory search path settings can be modified. #### Lib Files In addition, the correct [Lib file](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_distributing) must be linked using the Link Input settings. The Lib file name depends on the current processor target, according to the table below (see "Adding The Lib File"). The file name must be enclosed in quotes (") if the path contains spaces. Make sure to update all configurations (both Debug and Release). Using the *Project*, *Properties...* menu command, the project's Linker, Input properties are accessed so Additional Dependencies can be modified. #### Adding The Lib File The application's executable (Exe or Dll) must be linked with the correct Lib file, depending on the target environment (see "Updating Project Settings" above). If a Dll is used, it must be available and accessible at run-time for proper execution. The Dll used at run-time depends on the Lib file used at link time. If static linking is selected, the Dll is not required. All required Lib and Dll files are located in the product directories \Program Files (x86)\Softelvdm\SftButton DLL 3.0\Lib and \Program Files (x86)\Softelvdm\SftButton DLL 3.0\Dll. ##### Intel 64-Bit Operating Systems When building applications for 64-bit processors running Windows 10 and above, one of the following Lib files is used: | Lib File | Dll File | Description | | --- | --- | --- | | SftButton_x64_A_30.lib | SftButton_x64_A_30.dll | 64-bit Applications using** ANSI** character representation | | SftButton_x64_A_30_Static.lib | none - see section "Linking Statically" below | 64-bit Applications using** ANSI** character representation | | SftButton_x64_U_30.lib | SftButton_x64_U_30.dll | 64-bit Applications using** UNICODE ** character representation | | SftButton_x64_U_30_Static.lib | none - see section "Linking Statically" below | 64-bit Applications using** UNICODE** character representation | Depending on the Lib file used, the matching Dll must be distributed with your application. When using a statically linked library, the Dll is not required, but the application must be updated as described in section "Linking Statically" below. ##### Intel 32-Bit Operating Systems When building applications for Windows 10 and above, one of the following Lib files is used: | Lib File | Dll File | Description | | --- | --- | --- | | SftButton_IX86_A_30.lib | SftButton_IX86_A_30.dll | 32-bit Applications using** ANSI** character representation | | SftButton_IX86_A_30_Static.lib | none - see section "Linking Statically" below | 32-bit Applications using** ANSI** character representation | | SftButton_IX86_U_30.lib | SftButton_IX86_U_30.dll | 32-bit Applications using** UNICODE ** character representation | | SftButton_IX86_U_30_Static.lib | none - see section "Linking Statically" below | 32-bit Applications using** UNICODE** character representation | Depending on the Lib file used, the matching Dll must be distributed with your application. When using a statically linked library, the Dll is not required, but the application must be updated as described in section "Linking Statically" below. ##### ARM64 Operating Systems When building applications for ARM64 processors running Windows 11 and above, one of the following Lib files is used: | Lib File | Dll File | Description | | --- | --- | --- | | SftButton_ARM64_A_30.lib | SftButton_ARM64_A_30.dll | ARM64 Applications using** ANSI** character representation | | SftButton_ARM64_U_30.lib | SftButton_ARM64_U_30.dll | ARM64 Applications using** UNICODE ** character representation | Depending on the Lib file used, the matching Dll must be distributed with your application. #### Linking Statically This step is only required if a Lib file is selected above, that eliminates the Dll. If the Dll is distributed with your application and a suitable Lib file is chosen above, this step can be skipped. The entire project must be compiled with the SFTBUTTON_STATIC preprocessor symbol defined: Make sure to update all configurations (both Debug and Release). Using the *Project*, *Properties...* menu command, the project's C/C++, Preprocessor properties are accessed so Preprocessor Definitions can be modified. #### Resource Script When linking statically, your application must provide the resources for SftButton/DLL controls. This is accomplished by including the provided header file SftButtonResources.rci into the application's resource script. This file uses predefined ID values which cannot be changed. Make sure to update all configurations (both Debug and Release). ``` #include "SftButtonResources.rci" ``` #### Additional Lib Files > Depending on the Lib file used, it may also be necessary to add additional Lib files to the application. Typically, version.lib is required to allow successful linking. ``` version.lib ``` Make sure to update all configurations (both Debug and Release). Certain features of the control require [GDI+](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus) support. GDI+ is available on all supported Windows versions (Windows 10 and above). If you don't want to distribute gdiplus.dll, you can use the delayload feature of the linker by adding the following to your linker options: ``` /delayload:gdiplus.dll ``` This will allow the control to use GDI+, if available, and use alternate presentation methods if it is not available. Using the *Project*, *Properties...* menu command, the project's Linker, Input properties are accessed so Additional Dependencies can be modified. ## Creating a Dialog Resource *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_vc* This section describes how to add a button control to a dialog using Visual Studio. ### Adding a Button Control to a Dialog To add a SftButton/DLL control to a dialog, use the "Custom Control" toolbar button. Click on the button and then the dialog being designed to add a control. Once a custom control has been added to a dialog, you can edit the control properties by using the *View, Properties...* menu command. To define a SftButton/DLL control, enter the class **[SftButtonControl30](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/def_sftbutton_class)** in the edit field labeled *Class*. Enter the button's label in the *Caption* field (optional; the label can also be set later through [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control)). ### SftButton/DLL Control Styles To enter a SftButton/DLL window style in the *User Control Properties* dialog, use the following list to add the desired style values and enter the resulting hexadecimal value in the field marked *Style*. | Style | Value | ***Description*** | | --- | --- | --- | | WS_CHILD | 0x40000000 | Creates a child window. Usually required. | | WS_DISABLED | 0x08000000 | Creates a button control that is initially disabled. | | WS_GROUP | 0x00020000 | Specifies the first control of a group of controls. | | WS_TABSTOP | 0x00010000 | Specifies a control that can receive the keyboard focus when the user presses the TAB key. | | WS_VISIBLE | 0x10000000 | Creates a button control that is initially visible. Usually required. | The button control can be further customized at run-time by populating a SFTBUTTON_CONTROL structure and passing it to [SftButton_SetControlInfo](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setcontrolinfo). ### Test Mode In the dialog test mode offered by Visual Studio, the SftButton/DLL control will not be displayed. Instead, a gray box will show the location of the control. When using the Tab key to test the tab stops, the simulated SftButton/DLL control will not receive the input focus and appear not to have a tab stop defined. ## Using C *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_usingc* This section describes how to use SftButton/DLL in an application written using the C programming language. ### Adding SftButton/DLL to an Application Please see "[Building Applications](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_buildingapp)" to prepare a project for development with SftButton/DLL. | | | | --- | --- | | A) | Every source program making use of a SftButton/DLL control must include the required header file SftButton.h by using the #include directive. | ``` #include "SftButton.h" /* SftButton/DLL required header file */ ``` This include statement should appear after the #include statement. The file is located in the directory \Program Files (x86)\Softelvdm\SftButton DLL 3.0\Include (unless changed during the installation). The project settings may need to be updated so the #include file can be located (see "Building Applications" for more information). | | | | --- | --- | | B) | In order to use SftButton/DLL controls, an application must call the [SftButton_RegisterApp](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_registerapp) function. The call to this function is required so that SftButton/DLL window classes can be registered. This call has to be made before any SftButton/DLL controls are created. Add the following statement to your source code, where your application registers its window classes (normally during application initialization): | ``` SftButton_RegisterApp(hInstance); /* Use SftButton/DLL with this application */ ``` | | | | --- | --- | | C) | Once SftButton/DLL controls are no longer needed, an application must call the SftButton_UnregisterApp function. The call to this function is required so that SftButton/DLL window classes can be unregistered and cleanup processing can take place. This call has to be made after all SftButton/DLL controls have been destroyed (normally during application termination). | ``` SftButton_UnregisterApp(hInstance); /* No longer use SftButton/DLL */ ``` | | | | --- | --- | | D) | The application's executable (Exe or Dll) must be linked with the correct [Lib file](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_distributing), depending on the target environment. Please see "Building Applications" for more information. | ### Adding a Button Control There are two methods to add a button control to an application: - using dialog resources - using CreateWindow(Ex) Adding a button control using dialog resources is accomplished by using a resource editor to design a dialog. Once a button control is created, its window handle can be obtained by using the Windows GetDlgItem function. For more information, see [Creating a Dialog Resource](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_vc). Another method to create a button control is by using the CreateWindow(Ex) Windows call: ``` hwndButton = CreateWindow(TEXT(SFTBUTTON_CLASS), NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, 120, 32, hwndMain, (HMENU) IDC_BUTTON, hInstance, NULL); ``` For more information on the various parameters used, see the Windows [API](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_api) documentation. ### Configuring the Button A newly created button control is configured using [SftButton_SetControlInfo](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_setcontrolinfo). Populate a [SFTBUTTON_CONTROL](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/struct_sftbutton_control) structure with the desired images, [text](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_text), [colors](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_colors_gradients), border style, theme and behavior flags, then pass it to SftButton_SetControlInfo. ``` SFTBUTTON_CONTROL Ctl; ZeroMemory(&Ctl, sizeof(Ctl)); Ctl.cbSize = sizeof(Ctl); Ctl.nBorderStyle = SFTBUTTON_BORDER_STANDARD; Ctl.nUseThemes = SFTBUTTON_THEME_YES; Ctl.nDarkMode = SFTBUTTON_DARKMODE_AUTO; Ctl.nHighContrastMode = SFTBUTTON_HIGHCONTRAST_AUTO; /* populate Text, Picture1, colors, etc. */ SftButton_SetControlInfo(hwndButton, &Ctl); ``` ### Handling Notifications As with standard Windows controls, applications must respond to events and messages to cause controls to respond to user requests. For additional information, see [Notifications](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications). #### Responding to Clicks Respond to the WM_COMMAND / BN_CLICKED notification just as you would for a standard Windows push button: ``` case WM_COMMAND: { int id = LOWORD(wParam); int code = HIWORD(wParam); switch (id) { case IDC_BUTTON: if (code == BN_CLICKED) DoButtonAction(); break; } break; } ``` If the button has an attached [dropdown arrow](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown) (*fShowDropDown* is TRUE), clicks on the arrow are delivered as SFTBUTTONN_DROPDOWNCLICK instead of BN_CLICKED. Handle them through the same WM_COMMAND switch. ## Using C++/MFC *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_usingcpp* This section describes how to use SftButton/DLL in an application written [using C](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_usingc)++ and the Microsoft Foundation Class library (MFC). ### Adding SftButton/DLL to an Application Please see "[Building Applications](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_buildingapp)" to prepare a project for development with SftButton/DLL. | | | | --- | --- | | A) | Every source program making use of a SftButton/DLL control must include the required header file SftButton.h by using the #include directive. | ``` #include "SftButton.h" /* SftButton/DLL required header file */ ``` This include statement should appear after the #include statement or can be included at the end of stdafx.h. | | | | --- | --- | | B) | The source program SftButtonM.CPP must be added to your project. It is added to the project, without making any modifications to the file. Instead of adding it to the project, you can include the file using the #include directive. However, it must be included in a source file (*.CPP) as it is not a header file, and only one source file can #include the file SftButtonM.CPP. | ``` #include "SftButtonM.cpp" ``` | | | | --- | --- | | C) | In order to use SftButton/DLL controls, an application must call the [CSftButton::RegisterApp](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_registerapp) function. The preferred location is the InitInstance member function of your CWinApp-based application object: | ``` CSftButton::RegisterApp(); /* Use SftButton/DLL with this application */ ``` | | | | --- | --- | | D) | Once SftButton/DLL controls are no longer needed, an application must call the CSftButton::UnregisterApp function. The preferred location is the ExitInstance member function of your CWinApp-based application object: | ``` CSftButton::UnregisterApp(); /* No longer use SftButton/DLL */ ``` | | | | --- | --- | | E) | The application's executable (Exe or Dll) must be linked with the correct [Lib file](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_distributing), depending on the target environment. Please see "Building Applications" for more information. | ### Adding a Button Control ClassWizard does not support new classes such as [CSftButton](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_csftbutton), so any button control instance variables, notification handlers, message map entries, etc., have to be added manually. There are two methods to add a button control to an application: - using dialog resources - using [CSftButton::Create](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_create) Adding a button control using dialog resources is accomplished by using a resource editor to design a dialog. For more information, see [Creating a Dialog Resource](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_vc). Once a button control is created, its CSftButton-based object can be obtained by using the Windows GetDlgItem function or attached to a CSftButton object using SubclassDlgItem: ``` CSftButton * pButton; pButton = (CSftButton *) GetDlgItem(IDC_BUTTON); ``` or ``` CSftButton m_Button; m_Button.SubclassDlgItem(IDC_BUTTON, this); ``` Another method to create a button control is by using the CSftButton::Create member function. ``` CSftButton m_Button; m_Button.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(10,10,130,42), pParentWnd, IDC_BUTTON); ``` ### Handling Notifications As with standard Windows controls, applications must respond to events and messages to cause controls to respond to user requests. For additional information, see [Notifications](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications). #### Responding to Clicks ``` // Event handler prototype added to dialog/window class afx_msg void OnButtonClicked(); // Event handler(s) added to message map BEGIN_MESSAGE_MAP(CSampleDialog, CDialog) ON_BN_CLICKED(IDC_BUTTON, OnButtonClicked) END_MESSAGE_MAP() // Event handler implementation void CSampleDialog::OnButtonClicked() { // respond to the click } ``` If the button has an attached [dropdown arrow](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_dropdown), clicks on the arrow are delivered as SFTBUTTONN_DROPDOWNCLICK. Use ON_SFTBUTTONN_DROPDOWNCLICK in the message map. ## MFC and Notifications *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_notificationsmfc* [Notifications](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/i_notifications) can be handled by a button control's parent window or directly by the button control itself (in a derived class). WM_COMMAND messages are sent by the control to the parent window. The notification codes used are listed in section "Notifications". ### Parent Window If you want to handle Windows notification messages sent by a button control to its parent (usually a class derived from CDialog or CView), add a message-map entry and a message-handler member function to the parent class for each notification. Message-map entries take the following form for WM_COMMAND and WM_NOTIFY notifications: ``` ON_Notification( id, memberFxn ) ``` The parent's function prototype is as follows: ``` /* for WM_COMMAND notifications */ afx_msg void memberFxn( ); ``` ``` /* for WM_NOTIFY notifications */ afx_msg void memberFxn(NMHDR * pNotifyStruct, LRESULT* result); ``` *Notification* specifies one of the available notification codes listed in Notifications. *id *specifies the child window ID of the control sending the notification and *memberFxn* is the name of the parent member function in your application which handles the notification. ### Example ``` // Event handler prototype added to dialog/window class afx_msg void OnButtonClicked(); // Event handler(s) added to message map BEGIN_MESSAGE_MAP(CSampleDialog, CDialog) ON_BN_CLICKED(IDC_BUTTON, OnButtonClicked) END_MESSAGE_MAP() // Event handler implementation void CSampleDialog::OnButtonClicked() { // respond to the click } ``` ### Derived Objects By overriding the OnChildNotify function of an object derived from [CSftButton](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/function_csftbutton), you can handle messages in the object's class. The parameters are as documented in Notifications. Please see the MFC documentation for additional information regarding the OnChildNotify function. However, the use of message reflection as shown next is the preferred method to handle messages. MFC defines the ON_CONTROL_REFLECT and ON_NOTIFY_REFLECT macros which allow adding notifications directly to the message map. SftButton/DLL implements all required macros based on ON_CONTROL_REFLECT and ON_NOTIFY_REFLECT. See the MFC documentation for more information on message reflection. Message-map entries take the following form: ``` ON_Notification_REFLECT( memberFxn ) ``` ## Distributing the Dlls *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_distributing* Distributing the DLLs included with SftButton DLL 3.0 is only possible in accordance with the licensing agreement. The licensing agreement is furnished with the purchase of SftButton DLL 3.0. The DLLs contain your license number and are serialized. Modification of the original DLLs as included with the product is not permitted to insure that no incompatibilities exist between different software packages that use SftButton DLL 3.0. Any install procedure that is used to install DLLs which are included with SftButton DLL 3.0 must do proper version checking. > Applications you create with SftButton/DLL for distribution must be complete end-user applications. It is not possible to distribute the controls to unlicensed users for development purposes. This means that your distributed end-user application cannot be a Debug build, cannot contain debug information, symbol information, etc. ### DLLs The following DLLs can be distributed royalty-free with your application in accordance with the licensing agreement. The licensing agreement is furnished with the purchase of SftButton DLL 3.0. The application's executable (Exe or DLL) must be linked with the correct LIB file, depending on the target environment and the compiler used. The DLL must be available and accessible at run-time for proper execution (unless static [linking](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_buildingapp) is used). The DLL used at run-time depends on the LIB file used at link time. For the required DLL, please see "Building Applications". If the application is linked statically to SftButton/DLL 3.0, a DLL is not required. All required files can be found in the directory \Program Files (x86)\Softelvdm\SftButton DLL 3.0\Lib and \Program Files (x86)\Softelvdm\SftButton DLL 3.0\DLL, unless changed during the installation. Please note that available processor support depends on the installed and purchased product versions. ### GDI+ (Optional) Certain features of the control require [GDI+](https://softelvdm.com/Documentation/SftButton%20DLL%203%200/Topic/g_gdiplus) support. GDI+ is available on all supported Windows versions (Windows 10 and above). If GDI+ support is not available, the features are simply disabled and alternate presentation methods are used, if necessary. ### Target Directory The DLLs can be installed in the application's directory and can be used locally, without interfering with any other applications which may use other versions of SftButton DLL 3.0. The DLLs included with SftButton/DLL can also be installed in the Windows System directory. 64-bit DLLs are installed in the System32 directory and 32-bit DLLs are installed in the SysWOW64 directory. When installing DLLs in Windows directories, strict version checking and reference counting must be performed to avoid conflicts if different software packages use SftButton/DLL. ### Version Checking The DLLs included with SftButton/DLL carry proper version information. A shared DLL should only be replaced if its version information indicates that the existing DLL is older. Commercial installers and setup programs have built-in features to insure proper DLL versioning. See your installer's documentation for more information. ### Reference Counting If a DLL is installed into the Windows System(32) or SysWOW64 directory, it can potentially be installed and used by other applications also. It is required that any DLL installed in such a shared location keep proper reference counts by updating the proper Windows registry keys: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs Commercial installers and setup programs have built-in features to insure proper usage and reference counting. See your installer's documentation for more information. ## Technical Support for SftButton/DLL 3.0 *Source: https://softelvdm.com/Documentation/SftButton%20DLL%203%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 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/DLL 3.0* program group of the Start menu or from the *Product Updates* link on the About dialog. ### Before Contacting Product Support Your product purchase includes the first year's support subscription at no extra charge, which includes free product support. After the first year, the support subscription can be renewed for continued availability of product support, major versions and product maintenance. - Obtain help using the documentation provided at [https://softelvdm.com/Documentation/SftButton DLL 3 0](https://softelvdm.com/Documentation/SftButton%20DLL%203%200). - Review support information or download product maintenance from our web site. 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.