PowerShell + WinForms + Windows API
If you would like to use CreateRoundRectRgn
in PowerShell to create a round region form, you can do it like this:
using assembly System.Windows.Forms
using namespace System.Windows.Forms
using namespace System.Drawing
$code = @"
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);
"@
$Win32Helpers = Add-Type -MemberDefinition $code -Name "Win32Helpers" -PassThru
$form = [Form] @{
ClientSize = [Point]::new(400,100);
FormBorderStyle = [FormBorderStyle]::None;
BackColor = [SystemColors]::ControlDark
}
$form.Controls.AddRange(@(
($button1 = [Button] @{Location = [Point]::new(10,10); Text = "Close";
BackColor = [SystemColors]::Control;
DialogResult = [DialogResult]::OK })
))
$form.add_Load({
$hrgn = $Win32Helpers::CreateRoundRectRgn(0,0,$form.Width, $form.Height, 20,20)
$form.Region = [Region]::FromHrgn($hrgn)
})
$null = $form.ShowDialog()
$form.Dispose()

PowerShell + WPF
If you would like to do it in WPF, you can do it like this:
[xml]$xaml = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Window" WindowStyle="None"
Width= "400" Height="100"
Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
AllowsTransparency="True">
<Window.Clip>
<RectangleGeometry Rect="0,0,400,100" RadiusX="20" RadiusY="20"/>
</Window.Clip>
<Grid x:Name="Grid">
<Button x:Name="button1" Content="Close" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="75" Margin="10,10,0,0"/>
</Grid>
</Window>
"@
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
$window = [Windows.Markup.XamlReader]::Load($reader)
$button1 = $window.FindName("button1")
$button1.Add_Click({
$window.Close();
})
$window.ShowDialog()
