AdvancedButton Class

Represents a button with additional features such as customizable disabled colors, elevated mode, buffered fading animations, and more.

See the online help for an animated image example.

Definition

Namespace: KGySoft.WinForms.Controls
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
[ToolboxBitmapAttribute(typeof(Button))]
public class AdvancedButton : Button, 
	ISupportsFading<ControlAppearanceState>, IWin32Window
Inheritance
Object    MarshalByRefObject    Component    Control    ButtonBase    Button    AdvancedButton
Implements
ISupportsFadingControlAppearanceState, IWin32Window

Remarks

The AdvancedButton class offers the following features in addition to Button:
  • Images are displayed also when the FlatStyle property is System.
  • Elevated mode (see IsElevated). The shield icon is rendered also on a pre-Vista Windows.
  • Different rendering qualities (see TextRenderingQuality).
  • Adjustable colors in disabled state (see DisabledBackColor and DisabledForeColor).
  • Buffered fading animations with every FlatStyle (only on Vista and above with visual styles enabled, see FadingAnimationsEnabled and FadingAnimationOptions).
  • Small appearance changes and improvements (e.g. focus rectangle size and width, better fit of images, image shifts along with text in classic or popup appearance, fixed highlight fore color in high contrast mode with visual styles enabled, etc.).
  • Consistent font scaling on all platforms when per-monitor DPI awareness is enabled (see AutoScaleFont). Note that it affects font scaling only, so auto-sizing behavior still depends on the current platform.

Examples

The following image illustrates a few features of the AdvancedButton class, like displaying an image with System FlatStyle, elevated mode, rendering quality. The animation highlights the buffered animations support for non-System FlatStyles, which is not supported by a regular Button:

AdvancedButton in the KGySoft.WinForms.Example application

  Tip

The image above is from the example application. At the Releases page of the project repository you can download it as executable binaries as well.

Constructors

AdvancedButton Creates a new instance of AdvancedButton.

Properties

AutoScaleFont Gets or sets whether the Font should be automatically scaled when DPI changes and the current thread has per-monitor DPI awareness.
Default value: .
AutoSizeMode Gets or sets the mode by which the AdvancedButton automatically resizes itself.
BackColor Gets or sets the background color of the control in the current Enabled state.
(Overrides ButtonBaseBackColor)
DefaultSizeGets the default size of the control.
(Overrides ButtonBaseDefaultSize)
DisabledBackColor Gets or sets the background color when the control is not Enabled.
DisabledForeColor Gets or sets the text color when the control is not Enabled.
EnabledBackColor Gets or sets the background color when the control is Enabled.
EnabledForeColor Gets or sets the text color when the control is Enabled.
FadingAnimationDefaultSpeed Gets or sets the default fading animation speed for non-standard animations in milliseconds. Zero value means immediate change.
Default value: 500.
FadingAnimationOptions Gets or sets the fading options of the control.
Default value: StandardEffects.

See the online help for an animated image example.
FadingAnimationsEnabled Gets or sets whether fading animations are enabled for the control. Animations work on Windows Vista and above when rendering with visual styles.
Default value: .

See the online help for an animated image example.
FlatStyle Gets or sets the flat style appearance of the button control.
Default value: Standard.
FontGets or sets the font of the text displayed by the control.
(Overrides ControlFont)
ForeColor Gets or sets the foreground color of the control in the current Enabled state.
(Overrides ControlForeColor)
Image Gets or sets the image that is displayed on the button control.
IsElevated Gets or sets whether an elevated shield icon should be displayed on the button.
Default value: .

See the online help for an image example.
MaximumSizeGets or sets the size that is the upper limit that GetPreferredSize(Size) can specify.
(Overrides ControlMaximumSize)
MinimumSizeGets or sets the size that is the lower limit that GetPreferredSize(Size) can specify.
(Overrides ControlMinimumSize)
Text Gets or sets the text of the button.
(Overrides ButtonBaseText)
TextImageRelation Gets or sets the position of text and image relative to each other.
Default value: ImageBeforeText.
TextRenderingQuality Gets or sets the text rendering quality of the AdvancedButton.
Default value: SystemDefault.

See the online help for an image example.
UseCompatibleTextRendering Gets or sets whether to use the text rendering engine compatible with .NET Framework 1.x (GDI+) or not (GDI).
Default value: .

Methods

DisposeReleases the unmanaged resources used by the ButtonBase and optionally releases the managed resources.
(Overrides ButtonBaseDispose(Boolean))
GetPreferredSizeRetrieves the size of a rectangular area into which a control can be fitted.
(Overrides ButtonBaseGetPreferredSize(Size))
OnBackColorChangedRaises the BackColorChanged event.
(Overrides ControlOnBackColorChanged(EventArgs))
OnCreateControlRaises the CreateControl method.
(Overrides ControlOnCreateControl)
OnEnabledChangedRaises the EnabledChanged event.
(Overrides ButtonBaseOnEnabledChanged(EventArgs))
OnFontChangedRaises the FontChanged event.
(Overrides ButtonOnFontChanged(EventArgs))
OnForeColorChangedRaises the ForeColorChanged event.
(Overrides ControlOnForeColorChanged(EventArgs))
OnHandleCreatedRaises the HandleCreated event.
(Overrides ControlOnHandleCreated(EventArgs))
OnHandleDestroyedRaises the HandleDestroyed event.
(Overrides ControlOnHandleDestroyed(EventArgs))
OnKeyDownRaises the KeyDown event.
(Overrides ButtonBaseOnKeyDown(KeyEventArgs))
OnKeyUpRaises the KeyUp event.
(Overrides ButtonBaseOnKeyUp(KeyEventArgs))
OnMouseDownRaises the MouseDown event.
(Overrides ButtonBaseOnMouseDown(MouseEventArgs))
OnMouseEnterRaises the MouseEnter event.
(Overrides ButtonOnMouseEnter(EventArgs))
OnMouseLeaveRaises the MouseLeave event.
(Overrides ButtonOnMouseLeave(EventArgs))
OnMouseMoveRaises the MouseMove event.
(Overrides ButtonBaseOnMouseMove(MouseEventArgs))
OnMouseUpRaises the MouseUp event.
(Overrides ButtonOnMouseUp(MouseEventArgs))
OnPaddingChangedRaises the PaddingChanged event.
(Overrides ControlOnPaddingChanged(EventArgs))
OnPaint Implicitly calls the OnPaintState method, which raises both the Paint and PaintState events.
(Overrides ButtonBaseOnPaint(PaintEventArgs))
OnPaintState Paints the specified state of this control, and raises the PaintState event.
OnParentChangedRaises the ParentChanged event.
(Overrides ButtonBaseOnParentChanged(EventArgs))
OnParentFontChangedRaises the FontChanged event when the Font property value of the control's container changes.
(Overrides ControlOnParentFontChanged(EventArgs))
OnSizeChangedRaises the SizeChanged event.
(Overrides ControlOnSizeChanged(EventArgs))
OnVisibleChangedRaises the VisibleChanged event.
(Overrides ButtonBaseOnVisibleChanged(EventArgs))
WndProcProcesses Windows messages.
(Overrides ButtonWndProc(Message))

Events

PaintState Occurs when the control is painted in a specific state.

Extension Methods

GetFormatFlags Gets the formatting flags for the text of a custom drawn control.
(Defined by ControlExtensions)
GetScale Gets the current scale factor of the specified control. If per-monitor DPI awareness is not enabled, it always returns SystemScale.
(Defined by ScaleHelper)
GetScrollBarSize Gets the recommended width and height of scrollbars matching the current scaling of the specified control.
(Defined by ScaleHelper)
HasDefaultScaling Gets whether the display that the specified control belongs to has the same DPI as the initial DPI of the primary display.
(Defined by ScaleHelper)
ScaleHeight Scales the specified height by the vertical scale factor of the control.
(Defined by ScaleHelper)
ScaleSize Scales the specified size by the scale factor of the control.
(Defined by ScaleHelper)
ScaleWidth Scales the specified width by the horizontal scale factor of the control.
(Defined by ScaleHelper)
SetControlEnabled Sets the Enabled property of the child controls within the specified root control, or the Enabled property of the specified control itself, if it is not a recognized container control. By this way pages of a TabControl will remain selectable, a SplitContainer remains resizable, etc.
(Defined by ControlExtensions)
SetControlReadonly Recursively sets the read-only state in the children of the specified root control. Affects TextBoxBase and IReadOnlyCapable instances.
(Defined by ControlExtensions)
SetDoubleBuffered Sets the double buffered state of a control
(Defined by ControlExtensions)
SetStyle Sets a specified ControlStyles flag to either or . It calls the protected Control.SetStyle method on the specified control as if it was a public method.
(Defined by ControlExtensions)

See Also