๐Ÿ”น Kt-Window

KtWindow is a modern, feature-rich window/form component for WinForms that brings beautiful dark mode support, gradient backgrounds, and flicker-free rendering to your applications. Built with native Windows API optimizations for professional, smooth user experiences.


๐ŸŒŸ Cool Features

โœจ Automatic Dark Mode

Native Windows 10/11 title bar dark mode that automatically matches your theme.

public partial class MyWindow : KtWindow
{
    public MyWindow()
    {
        InitializeComponent();
        // Dark mode automatically applied based on KtColor.IsDark()
    }
}

How it works:

  • Automatically detects system theme or your custom theme

  • Updates title bar to match (dark or light)

  • No flickering during theme transitions

  • Native Windows 10/11 immersive dark mode API


๐ŸŽจ Gradient Backgrounds

Beautiful gradient backgrounds with zero code complexity.

Features:

  • Smooth gradients with any two colors

  • Adjustable angle for direction

  • Automatic theme updates

  • Flicker-free rendering


๐Ÿš€ Zero Flicker Rendering

Optimized with native Windows API for butter-smooth rendering.

What makes it flicker-free:

  • Native WS_EX_COMPOSITED style for hardware acceleration

  • Double buffering enabled by default

  • Optimized paint events

  • Smart invalidation (only redraws what changed)


๐Ÿ”„ Auto Theme Synchronization

Automatically updates when theme changes - no manual refresh needed!

Automatic updates when:

  • User switches between dark/light mode

  • Theme colors change

  • System theme changes


๐Ÿ’ช Drop Shadow Support

Beautiful drop shadow for borderless windows.


๐ŸŽฏ Smart Window Management

Intelligent features that just work.


Creating a KtWindow

Step 1: Inherit from KtWindow

Step 2: Set Background (Optional)

Step 3: Set Foreground (Optional)

That's it! You now have a modern window with dark mode support.


Properties

Background

Sets the window background (solid color or gradient).

Examples:


Foreground

Sets the window foreground color (text and UI elements).

Examples:


Text (Title)

Gets or sets the window title.

Examples:


IsDark / IsLight (Read-Only)

Detects current theme mode.

Examples:


Background & Foreground

Setting Background Colors

Solid Colors:

Gradient Colors:


Setting Foreground Colors


Dark Mode

Automatic Dark Mode

KtWindow automatically applies native dark mode to the title bar.

How it detects dark mode:

  1. Checks KtColor.IsDark() - your theme setting

  2. Applies Windows 10/11 immersive dark mode API

  3. Updates title bar color automatically

  4. Syncs with theme changes


Manual Dark Mode Control


Borderless Window Shadow

For modern borderless windows, KtWindow automatically adds a drop shadow:


Methods

Render()

Manually trigger a full window render.

When to use:

  • After changing multiple properties

  • After manual theme changes

  • To force visual update

Example:

What it does:

  • Updates ForeColor from Foreground

  • Updates BackColor from Background

  • Triggers RenderMode() for dark mode

  • Invalidates and updates display


RenderMode()

Updates the window's dark/light mode.

Example:

What it does:

  • Applies native Windows immersive dark mode

  • Updates title bar appearance

  • Adds shadow for borderless windows

  • Sets composited style for flicker-free rendering


Title()

Get or set the window title.

Examples:


GetForeground()

Gets the effective foreground color.

Example:

Use case:

  • When you need the actual foreground color

  • For child controls that inherit color

  • For custom painting


Snapshot()

Captures the window as an image.

Example:


Mirror()

Captures the screen area behind the window.

Example:

Use case:

  • Creating blur effects

  • Transparency effects

  • Acrylic/glass effects


Reset Methods


Advanced Features

Theme Change Events

KtWindow automatically subscribes to theme changes.

Manual subscription (if needed):


Property Change Notifications

KtWindow implements INotifyPropertyChanged.

Example:


Custom Paint Background

Override for custom background rendering.


Native API Optimizations

KtWindow uses several Windows APIs for optimal performance:

1. DWM (Desktop Window Manager) APIs:

2. Window Styles:

3. Message Handling:


Best Practices

โœ… DO: Use Theme Colors

โœ… DO: Use Gradients for Visual Impact

โœ… DO: Let Automatic Updates Handle Theme Changes

โŒ DON'T: Call Render() Excessively

โŒ DON'T: Set Opacity in Designer

โœ… DO: Use Title() Method


Complete Examples

Example 1: Basic Modern Window


Example 2: Borderless Window with Shadow


Example 3: Dynamic Theme-Aware Window


Example 4: Window with Progress Title


Summary

KtWindow provides a complete modern window solution with:

  • โœ… Automatic Dark Mode - Native Windows 10/11 title bar theming

  • โœ… Gradient Backgrounds - Beautiful, smooth gradients with any angle

  • โœ… Zero Flicker - Native API optimizations for smooth rendering

  • โœ… Auto Theme Sync - Updates automatically when theme changes

  • โœ… Drop Shadows - Beautiful shadows for borderless windows

  • โœ… Smart Management - Title updates, snapshots, and more

  • โœ… Easy to Use - Just inherit from KtWindow and go!

For more information about KtColor, KtBrush, and other KimTools components, refer to their respective documentation.

Last updated

Was this helpful?