How to show a TIF image full screen on secondary monitor in C#?
I have a series of i开发者_运维知识库mages stored in a directory and want to show them successively on the secondary monitor in full screen mode.
I have no clues whatsoever of displaying image full screen mode.. Any idea how to do this in C#?
Use SetWindowPos from the WinAPI.
Example:
[DllImport("user32.dll")]
public static extern void SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int X, int Y, int width, int height, uint flags);
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
SetWindowPos(this.Handle, IntPtr.Zero, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, 64);
}
replace PrimaryScreen
with the choosen screen.
I don't know what all can be done with the image. you can just use a Picturebox or create your on control and display it with GDI.
You can just create a borderless form, using its BackgroundImage to show the image. Make it as large as the secondary screen. Like this:
public static Form ShowImage(Image image) {
Form frm = new Form();
frm.ControlBox = false;
frm.FormBorderStyle = FormBorderStyle.None;
frm.BackgroundImage = image;
frm.BackgroundImageLayout = ImageLayout.Zoom;
Screen scr = Screen.AllScreens.Length > 1 ? Screen.AllScreens[1] : Screen.PrimaryScreen;
frm.Location = new Point(scr.Bounds.Left, scr.Bounds.Top);
frm.Size = scr.Bounds.Size;
frm.BackColor = Color.Black;
frm.Show();
return frm;
}
Note that it returns a Form object, call its Close() method to get rid of the image again.
精彩评论