簡體   English   中英

如何在C#中沒有窗口的情況下顯示圖像

[英]how to display an image without a window in C#

我想知道如何在沒有打開窗口的情況下打開圖像,因此它就像圖像漂浮在我的桌面上而沒有邊框。 謝謝

你想要做的是在屏幕上繪制一個圖像,周圍沒有可見的窗口邊框。 是否創建窗口是一個完全不同的問題。 事實證明,你必須有一個窗口。 它只是不可見。 所以:

創建一個窗口,確保在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 );
}

如果你想要的只是一個啟動畫面 ,那么就有一個框架組件: http//msdn.microsoft.com/en-us/library/system.windows.splashscreen.aspx

顯示沒有標題欄的窗口

如果是winforms -

FormBorderStyle = None
ControlBox = false

取自 - 具有調整大小框架且沒有標題欄的Windows窗體?

在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>

取自 - 是否可以在標題欄中顯示沒有圖標的wpf窗口?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM