Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display an image without a window in C#

Tags:

c#

image

I would like to know how to open an image without having a window open, so its like the the image is floating on my desktop with no border. thanks

like image 479
Parker Olson Avatar asked Dec 01 '11 22:12

Parker Olson


People also ask

How can I display image in C?

The C language itself doesn't have any built-in graphics capability. You can use a graphics toolkit like Qt, gtk, wxWidgets, etc. You could also construct an image file (BMP is pretty simple), and then launch (using fork and exec) an application to view it.

How do I display an image in Visual Studio?

Display an image - designer In Visual Studio, use the Visual Designer to display an image. Open the Visual Designer of the form containing the control to change. Select the control. In the Properties pane, select the Image or BackgroundImage property of the control.


3 Answers

What you want to do is to draw an image on the screen without a visible window border around it. Whether a window will be created is a totally different question. And as it turns out, you have to have a window. It just won't be visible. So:

Create a window, making sure to set the following in InitializeComponent():

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

Then, override OnPaintBackground for that window, as follows:

protected override void OnPaintBackground( WinForms.PaintEventArgs e )
{
    e.Graphics.DrawImage( Image, 0, 0, Width, Height );
}
like image 125
Mike Nakis Avatar answered Oct 04 '22 08:10

Mike Nakis


If all you want is a splash screen, there's a framework component for that: http://msdn.microsoft.com/en-us/library/system.windows.splashscreen.aspx

like image 45
dtanders Avatar answered Oct 04 '22 06:10

dtanders


Show a window without the title bar

In case of winforms -

FormBorderStyle = None
ControlBox = false

taken from - Windows Form with Resizing Frame and no Title Bar?

In case of XAML use this to show window without title bar -

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

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

like image 35
Unmesh Kondolikar Avatar answered Oct 04 '22 06:10

Unmesh Kondolikar