New to Telerik UI for WinForms? Start a free 30-day trial

Represents a form with customizable shape and appearance that can be themed.

Definition

Namespace:Telerik.WinControls.UI

Assembly:Telerik.WinControls.UI.dll

Syntax:

C#
public class ShapedForm : Form, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, IContainerControl, IThemeChangeListener

Inheritance: objectMarshalByRefObjectComponentControlScrollableControlContainerControlFormShapedForm...

Derived Classes: MiniToolBarBaseRadCalloutFormRadDiagramSettingsPaneRadFlyoutFormRadOverlayFormRadSplashScreenFormIntelliPromptBase...

Implements: IBindableComponentIComponentIContainerControlIDisposableIDropTargetISynchronizeInvokeIThemeChangeListenerIWin32Window...

Inherited Members Form.SetVisibleCore(bool)Form.Activate()Form.ActivateMdiChild(Form)Form.AddOwnedForm(Form)Form.AdjustFormScrollbars(bool)Form.Close()Form.CreateControlsInstance()Form.CreateHandle()Form.DefWndProc(ref Message)Form.ProcessMnemonic(char)Form.CenterToParent()Form.CenterToScreen()Form.LayoutMdi(MdiLayout)Form.OnActivated(EventArgs)Form.OnBackgroundImageChanged(EventArgs)Form.OnBackgroundImageLayoutChanged(EventArgs)Form.OnClosing(CancelEventArgs)Form.OnClosed(EventArgs)Form.OnFormClosing(FormClosingEventArgs)Form.OnFormClosed(FormClosedEventArgs)Form.OnCreateControl()Form.OnDeactivate(EventArgs)Form.OnEnabledChanged(EventArgs)Form.OnEnter(EventArgs)Form.OnFontChanged(EventArgs)Form.OnHandleCreated(EventArgs)Form.OnHandleDestroyed(EventArgs)Form.OnHelpButtonClicked(CancelEventArgs)Form.OnLayout(LayoutEventArgs)Form.OnMaximizedBoundsChanged(EventArgs)Form.OnMaximumSizeChanged(EventArgs)Form.OnMinimumSizeChanged(EventArgs)Form.OnInputLanguageChanged(InputLanguageChangedEventArgs)Form.OnInputLanguageChanging(InputLanguageChangingEventArgs)Form.OnVisibleChanged(EventArgs)Form.OnMdiChildActivate(EventArgs)Form.OnMenuStart(EventArgs)Form.OnMenuComplete(EventArgs)Form.OnPaint(PaintEventArgs)Form.OnResize(EventArgs)Form.OnDpiChanged(DpiChangedEventArgs)Form.OnGetDpiScaledSize(int, int, ref Size)Form.OnRightToLeftLayoutChanged(EventArgs)Form.OnTextChanged(EventArgs)Form.ProcessCmdKey(ref Message, Keys)Form.ProcessDialogKey(Keys)Form.ProcessDialogChar(char)Form.ProcessKeyPreview(ref Message)Form.ProcessTabKey(bool)Form.RemoveOwnedForm(Form)Form.Select(bool, bool)Form.GetScaledBounds(Rectangle, SizeF, BoundsSpecified)Form.SetDesktopBounds(int, int, int, int)Form.SetDesktopLocation(int, int)Form.Show(IWin32Window)Form.ShowDialog()Form.ShowDialog(IWin32Window)Form.ToString()Form.UpdateDefaultButton()Form.OnStyleChanged(EventArgs)Form.ValidateChildren()Form.ValidateChildren(ValidationConstraints)Form.AcceptButtonForm.ActiveFormForm.ActiveMdiChildForm.AllowTransparencyForm.AutoScrollForm.AutoSizeForm.AutoSizeModeForm.AutoValidateForm.CancelButtonForm.ClientSizeForm.ControlBoxForm.DefaultImeModeForm.DefaultSizeForm.DesktopBoundsForm.DesktopLocationForm.DialogResultForm.HelpButtonForm.IconForm.IsMdiChildForm.IsMdiContainerForm.IsRestrictedWindowForm.KeyPreviewForm.LocationForm.MaximizedBoundsForm.MaximumSizeForm.MainMenuStripForm.MenuForm.MinimumSizeForm.MaximizeBoxForm.MdiChildrenForm.MdiParentForm.MergedMenuForm.MinimizeBoxForm.ModalForm.OpacityForm.OwnedFormsForm.OwnerForm.RestoreBoundsForm.RightToLeftLayoutForm.ShowInTaskbarForm.ShowIconForm.ShowWithoutActivationForm.SizeForm.SizeGripStyleForm.StartPositionForm.TextForm.TopLevelForm.TopMostForm.TransparencyKeyForm.WindowStateForm.AutoSizeChangedForm.AutoValidateChangedForm.HelpButtonClickedForm.MaximizedBoundsChangedForm.MaximumSizeChangedForm.MinimumSizeChangedForm.ActivatedForm.DeactivateForm.FormClosingForm.FormClosedForm.LoadForm.MdiChildActivateForm.MenuCompleteForm.MenuStartForm.InputLanguageChangedForm.InputLanguageChangingForm.RightToLeftLayoutChangedForm.ShownForm.DpiChangedForm.ResizeBeginForm.ResizeEnd...

Constructors

Initializes a new instance of the ShapedForm class.

C#
public ShapedForm()

Properties

Allow form's resize

C#
[Browsable(true)]
public bool AllowResize { get; set; }

Gets or sets the BackColor of the ShapedForm.

C#
public override Color BackColor { get; set; }

Overrides: Form.BackColor

Gets or sets the pen alignment for the border.

C#
public PenAlignment BorderAlignment { get; set; }

Gets or sets the form's border color

C#
[Browsable(true)]
public Color BorderColor { get; set; }

Gets or sets the outline used to paint the form's border.

C#
protected GraphicsPath BorderPath { get; set; }

Gets or sets the form's border width

C#
[Browsable(true)]
public virtual int BorderWidth { get; set; }

Gets or sets the theme class name for the control.

C#
public string ControlThemeClassName { get; }

Implements: IThemeChangeListener.ControlThemeClassName

Adds the minimize-box window style so the form can be minimized or maximized from the taskbar.

C#
protected override CreateParams CreateParams { get; }

Overrides: Form.CreateParams

Enables or disables transparent background on Vista

C#
[Browsable(true)]
public bool EnableCompositionOnVista { get; set; }

Gets or sets the form's font

C#
[Browsable(true)]
public override Font Font { get; set; }

Overrides: Control.Font

Gets or sets the form's foreground color

C#
[Browsable(true)]
public override Color ForeColor { get; set; }

Overrides: Control.ForeColor

Gets or sets the FormBorderStyle of the Form.

C#
public FormBorderStyle FormBorderStyle { get; set; }

Gets or sets the path used as the form's non-rectangular window region.

C#
protected GraphicsPath OuterPath { get; set; }

Gets or sets an instance of the Shape object of a form. The shape of the form is responsible for providing its' border(s) with custom shape.

C#
[Browsable(true)]
public virtual ElementShape Shape { get; set; }

Some predefined shapes are available, like RoundRectShape or EllipseShape. CustomShape offers a way to specify element's shape with a sequence of points and curves using code or the design time ElementShapeEditorUITypeEditor.

Gets the internal themed control that supplies this form's visual settings.

C#
protected RadControl ShapedControl { get; }

Gets or sets theme name.

C#
[Browsable(true)]
public string ThemeName { get; set; }

Gets or sets the windows related setting. Exposes API to round the form's corners on Windows 11. Using the rounded corners API with form's shapes that are not rectangular may lead to unexpected results.

C#
public WindowsSettings WindowsSettings { get; set; }

Methods

Applies the new application theme when the notification includes a theme name.

C#
protected virtual void ApplicationThemeChanged(object sender, ThemeChangedEventArgs args)
Parameters:senderobject

The source of the theme-change notification.

argsThemeChangedEventArgs

The notification containing the new theme name.

When a shape is set, rebuilds the border paths and window region; round rectangles use a native rounded region.

C#
protected virtual void ApplyShape()

Applies the theme to the internal control and refreshes the form's non-client frame.

C#
protected virtual void ApplyTheme(string themeName)
Parameters:themeNamestring

The theme name to apply.

Creates the border outline from the current shape and form bounds.

C#
protected virtual GraphicsPath CreateBorderPath()
Returns:

GraphicsPath

The graphics path used to paint the shaped form's border.

Clean up any resources being used.

C#
protected override void Dispose(bool disposing)
Parameters:disposingbool

true if managed resources should be disposed; otherwise, false.

Overrides: Form.Dispose(bool)

Maps border and caption points to the Windows non-client hit-test codes used for resizing and moving.

C#
protected virtual int GetHitTest(Point point)
Parameters:pointPoint

The point to test in form-client coordinates.

Returns:

int

The non-client hit-test code for a border, corner, or caption point; otherwise, the client-area code.

Determines whether the current shape is a RoundRectShape that can use a native rounded region.

C#
protected virtual bool IsRectangularShape(ref int radius)
Parameters:radiusint

Receives twice the shape's corner radius when the shape is a round rectangle.

Returns:

bool

true when the current shape is a round rectangle; otherwise, false.

Returns the low-order 16 bits of a packed message value as a signed integer.

C#
public static short LOWORD(int number)
Parameters:numberint

The value containing the low-order word.

Returns:

short

The signed 16-bit value represented by the low-order word.

Initializes optional DWM composition and monitor-DPI state when the form loads.

C#
protected override void OnLoad(EventArgs e)
Parameters:eEventArgs

The event data.

Overrides: Form.OnLoad(EventArgs)

Applies deferred DPI scaling once the form is fully within its destination screen.

C#
protected override void OnMove(EventArgs e)
Parameters:eEventArgs

The event data.

Overrides: Control.OnMove(EventArgs)

Paints the shaped form frame instead of the standard rectangular background.

C#
protected override void OnPaintBackground(PaintEventArgs e)
Parameters:ePaintEventArgs

The paint event data.

Overrides: ScrollableControl.OnPaintBackground(PaintEventArgs)

Marks the form as moving or resizing so DPI changes can be deferred until the operation ends.

C#
protected override void OnResizeBegin(EventArgs e)
Parameters:eEventArgs

The event data.

Overrides: Form.OnResizeBegin(EventArgs)

Ends the move/resize state and applies any deferred DPI scaling.

C#
protected override void OnResizeEnd(EventArgs e)
Parameters:eEventArgs

The event data.

Overrides: Form.OnResizeEnd(EventArgs)

Applies the configured Windows rounded-corner setting after the form is shown.

C#
protected override void OnShown(EventArgs e)
Parameters:eEventArgs

The event data.

Overrides: Form.OnShown(EventArgs)

Rebuilds the shape geometry and repaints the frame after the form size changes.

C#
protected override void OnSizeChanged(EventArgs e)
Parameters:eEventArgs

The event data.

Overrides: Control.OnSizeChanged(EventArgs)

Handles theme change events to update the form's appearance.

C#
public void OnThemeChanged(ThemeChangedEventArgs e)
Parameters:eThemeChangedEventArgs

The theme changed event arguments.

Implements: IThemeChangeListener.OnThemeChanged(ThemeChangedEventArgs)

When the border width is positive, paints the configured path or a rectangular fallback.

C#
protected virtual void PaintBorder(Graphics g)
Parameters:gGraphics

The graphics surface used to paint the border.

Paints the frame background and border; composition mode skips border drawing when the form has a native border.

C#
protected virtual void PaintFrame(Graphics g)
Parameters:gGraphics

The graphics surface used to paint the frame.

Scales the form only when Telerik DPI scaling is enabled.

C#
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
Parameters:factorSizeF

The scaling factors to apply.

specifiedBoundsSpecified

Indicates which bounds values are being scaled.

Overrides: Form.ScaleControl(SizeF, BoundsSpecified)

Limits size changes in the designer while the form's client size is being updated.

C#
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
Parameters:xint

The requested horizontal position.

yint

The requested vertical position.

widthint

The requested width.

heightint

The requested height.

specifiedBoundsSpecified

Indicates which bounds values are being applied.

Overrides: Form.SetBoundsCore(int, int, int, int, BoundsSpecified)

Suspends designer size limiting while the base form applies a new client size.

C#
protected override void SetClientSizeCore(int x, int y)
Parameters:xint

The requested client width.

yint

The requested client height.

Overrides: Form.SetClientSizeCore(int, int)

Handles non-client painting and hit testing for shaped forms, along with DPI and taskbar-window messages.

C#
protected override void WndProc(ref Message m)
Parameters:mMessage

The Windows message to process.

Overrides: Form.WndProc(ref Message)