ZposDesktop 1.1.0
dotnet add package ZposDesktop --version 1.1.0
NuGet\Install-Package ZposDesktop -Version 1.1.0
<PackageReference Include="ZposDesktop" Version="1.1.0" />
<PackageVersion Include="ZposDesktop" Version="1.1.0" />
<PackageReference Include="ZposDesktop" />
paket add ZposDesktop --version 1.1.0
#r "nuget: ZposDesktop, 1.1.0"
#:package ZposDesktop@1.1.0
#addin nuget:?package=ZposDesktop&version=1.1.0
#tool nuget:?package=ZposDesktop&version=1.1.0
ZposDesktop
A Windows library that allows applications to keep their windows visible when the user activates "Show Desktop" (Win+D or taskbar button). Perfect for overlay applications, desktop widgets, monitoring tools, and other utilities that should remain accessible even when the desktop is shown.
Features
- 🖥️ Show Desktop Bypass: Keep your windows visible when users press Win+D or click "Show Desktop"
- 🔄 Smart Detection: Automatically detects desktop state changes across Windows versions
- 🎯 Selective Control: Register only specific windows that need to stay visible
- 📱 Multi-Version Support: Works on Windows 10, 11, and handles 24H2+ changes automatically
- 🧩 Easy Integration: Simple C# wrapper with P/Invoke declarations included
- 🔧 Automatic Cleanup: Built-in resource management and cleanup helpers
Quick Start
1. Build the Library
# Clone the repository
git clone https://github.com/yourusername/ZposDesktop.git
cd ZposDesktop
# Build using Visual Studio or MSBuild
msbuild ZposDesktop.sln /p:Configuration=Release
2. Basic Usage (C#)
using ZposDesktop;
// Initialize the library (call once at startup)
if (ZposDesktopHelper.InitializeWithAutoCleanup())
{
// Register your main form to stay visible during "Show Desktop"
ZposDesktopHelper.RegisterFormWithAutoCleanup(this);
// Optional: Get notified when desktop state changes
ZposDesktop.SetDesktopStateCallback(OnDesktopStateChanged);
}
private static void OnDesktopStateChanged(DesktopState state)
{
Console.WriteLine($"Desktop state changed to: {state}");
}
3. Manual Control
// Initialize
ZposDesktop.Initialize();
// Register specific windows
ZposDesktop.RegisterWindow(myForm);
ZposDesktop.RegisterWindow(anotherWindow.Handle);
// Check current state
var currentState = ZposDesktop.GetDesktopState();
if (currentState == DesktopState.ShowingDesktop)
{
// Desktop is currently being shown
}
// Cleanup when done
ZposDesktop.Shutdown(); // Note: renamed from Finalize
How It Works
ZposDesktop works by:
- Monitoring Desktop State: Uses Windows event hooks to detect when "Show Desktop" is activated
- Z-Order Management: Manipulates window Z-order to position registered windows appropriately
- Version Compatibility: Adapts its behavior based on Windows version and desktop composition changes
- Resource Tracking: Maintains a registry of managed windows and their states
The library creates invisible helper windows that act as Z-order anchors, ensuring your registered windows appear in the correct layer when the desktop is shown.
Architecture
- ZposDesktop.dll: Native C++ library that handles Windows API interactions
- ZposDesktop.cs: C# wrapper providing easy .NET integration
- Helper Classes: Automatic resource management and cleanup utilities
API Reference
Core Methods
Method | Description |
---|---|
Initialize() |
Initialize the library (required first call) |
Shutdown() |
Clean up resources |
RegisterWindow(hwnd/form) |
Register a window to stay visible |
UnregisterWindow(hwnd/form) |
Unregister a previously registered window |
GetDesktopState() |
Get current desktop state |
SetDesktopStateCallback(callback) |
Set callback for state changes |
RefreshWindowPositions() |
Force refresh of window positions |
IsWindowRegistered(hwnd/form) |
Check if window is registered |
Desktop States
ShowingWindows
: Normal state, all windows visibleShowingDesktop
: Desktop is being shown, registered windows stay visible
Helper Methods
ZposDesktopHelper.InitializeWithAutoCleanup()
: Initialize with automatic cleanup on app exitZposDesktopHelper.RegisterFormWithAutoCleanup(form)
: Register form with automatic cleanup on dispose
System Requirements
- OS: Windows 10 or later
- Framework: .NET Framework 4.5+ or .NET 5+
- Architecture: x64 (can be adapted for x86)
Use Cases
Desktop Widgets
// Perfect for weather widgets, system monitors, etc.
public partial class WeatherWidget : Form
{
protected override void SetVisibleCore(bool value)
{
base.SetVisibleCore(value);
if (value && !ZposDesktop.IsWindowRegistered(this))
{
ZposDesktop.RegisterWindow(this);
}
}
}
Overlay Applications
// For gaming overlays, screen annotation tools, etc.
public class GameOverlay : Form
{
public GameOverlay()
{
InitializeComponent();
this.TopMost = true;
this.ShowInTaskbar = false;
// Stay visible even during "Show Desktop"
ZposDesktop.RegisterWindow(this);
}
}
Monitoring Tools
// For system monitoring, network tools, etc.
public class SystemMonitor : Form
{
private void SystemMonitor_Load(object sender, EventArgs e)
{
// Register to stay accessible
ZposDesktop.RegisterWindow(this);
// Monitor desktop state changes
ZposDesktop.SetDesktopStateCallback(state =>
{
this.Invoke(() =>
{
// Update UI based on desktop state
statusLabel.Text = $"Desktop State: {state}";
});
});
}
}
Building from Source
Prerequisites
- Visual Studio 2019 or later
- Windows 10 SDK
- .NET development workload
Build Steps
- Open
ZposDesktop.sln
in Visual Studio - Select your target configuration (Debug/Release)
- Build Solution (Ctrl+Shift+B)
- Output files will be in
bin/Release
orbin/Debug
Project Structure
ZposDesktop/
├── ZposDesktop.cpp # Main implementation
├── ZposDesktop.h # C++ header
├── ZposDesktop.cs # C# wrapper
├── dllmain.cpp # DLL entry point
├── framework.h # Windows headers
├── pch.h/cpp # Precompiled headers
└── ZposDesktop.sln # Visual Studio solution
Troubleshooting
Common Issues
DLL not found
- Ensure
ZposDesktop.dll
is in the same directory as your executable - Check that you're using the correct architecture (x64 vs x86)
Windows not staying visible
- Verify the window is properly registered with
IsWindowRegistered()
- Check that initialization was successful
- Some window types may not be compatible (e.g., certain system dialogs)
Performance issues
- The library uses minimal resources, but avoid registering/unregistering windows frequently
- Use the callback system instead of polling
GetDesktopState()
Debug Mode
Build in Debug configuration for additional logging and error checking.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Windows desktop management techniques inspired by various Windows internals resources
- Thanks to the community for testing across different Windows versions
Product | Versions Compatible and additional computed target framework versions. |
---|---|
native | native is compatible. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release with support for Windows 10/11 desktop state detection