【问题标题】:how to display an image without a window in C#如何在 C# 中显示没有窗口的图像
【发布时间】:2012-01-11 01:30:04
【问题描述】:

我想知道如何在不打开窗口的情况下打开图像,所以它就像图像漂浮在我的桌面上没有边框一样。谢谢

【问题讨论】:

  • 这个Link可以帮助你。你需要使用相同的技术逐像素绘制图片。

标签: c# image


【解决方案1】:

【讨论】:

    【解决方案2】:

    显示一个没有标题栏的窗口

    在winforms的情况下-

    FormBorderStyle = None
    ControlBox = false
    

    取自 - Windows Form with Resizing Frame and no Title Bar?

    在 XAML 的情况下,使用它来显示没有标题栏的窗口 -

    <Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Width="640" Height="480" 
        WindowStyle="None"
        AllowsTransparency="True"
        ResizeMode="CanResizeWithGrip">
    
        <!-- Content -->
    
    </Window>
    

    取自 - Is it possible to display a wpf window without an icon in the title bar?

    【讨论】:

      【解决方案3】:

      您要做的是在屏幕上绘制一个没有可见窗口边框的图像。是否会创建一个窗口是一个完全不同的问题。事实证明,你必须有一个窗口。它只是不可见。所以:

      创建一个窗口,确保在InitializeComponent()中设置以下内容:

      this.ControlBox = false;
      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
      this.MaximizeBox = false;
      this.MinimizeBox = false;
      this.ShowIcon = false;
      this.ShowInTaskbar = false;
      

      然后,为该窗口覆盖OnPaintBackground,如下所示:

      protected override void OnPaintBackground( WinForms.PaintEventArgs e )
      {
          e.Graphics.DrawImage( Image, 0, 0, Width, Height );
      }
      

      【讨论】:

        猜你喜欢
        • 2017-08-19
        • 2011-05-05
        • 1970-01-01
        • 1970-01-01
        • 2021-11-20
        • 2022-12-11
        • 2013-07-01
        • 1970-01-01
        • 2016-11-14
        相关资源
        最近更新 更多