Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Display JPG in Full Screen Mode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zacks@construction-imaging.com - 16 Oct 2007 13:36 GMT
I know how to use the image class to display a JPG image in a
PictureBox. I would like to be able to display the image in full
screen mode. I have searched for code examples but cannot locate any.
Any help would be appreciated.
Rad [Visual C# MVP] - 16 Oct 2007 13:58 GMT
>I know how to use the image class to display a JPG image in a
>PictureBox. I would like to be able to display the image in full
>screen mode. I have searched for code examples but cannot locate any.
>Any help would be appreciated.

It's not glamorous, but a simple way is to perhaps  put the picture
box on a form, size it to be about the size of the form, set the
border style to none, anchor the picturebox to the top, left, bottom
and right and depending on your usage requirement, set the picture box
to either autosize or stretch

--
http://bytes.thinkersroom.com
zacks@construction-imaging.com - 17 Oct 2007 15:19 GMT
> On Tue, 16 Oct 2007 05:36:52 -0700, za...@construction-imaging.com
> wrote:
[quoted text clipped - 9 lines]
> and right and depending on your usage requirement, set the picture box
> to either autosize or stretch

I had thought that there must be some built in .NET method that would
do this but apparently there is not. But as you suggest, it can be
done "manually". Here's how.

Create a form to display the full screen image. Size in design mode is
irrelevant. But set these properties:

BackColor - To what ever color you prefer displayed in areas not
covered by the image itself. I prefer Black.
FormBorderStyle - None
StartPosition - Manual
Top - 0
Left - 0
WindowState - Maximized (strange that this is required. if you don't
set it the form doesn't go completely full screen)

Add a PictureBox control to the form. Set these properties:

Location - 0, 0
SizeMode - Zoom (to ensure the image is displayed in the proper aspect
ratio)
Make the size equivalent to the size of the form's content area.
Set the Anchor property to Top, Bottom, Left, Right.

The code to display the image:

Instantiate the form.
Set the Width property to Screen.PrimaryScreen.WorkingArea.Width
Set the Height property to Screen.PrimaryScreen.WorkingArea.Height
Set the PictureBox.Image property to an instance of the Image class
that has had the JPG loaded into it.
Show the form with the ShowDialog method.

Be sure to add an OnClick event handler for the PictureBox to close
the form when you click on it. I also added a form KeyDown event
handler so I could also close the form by hitting ESC. There's no way
to close the form if neither of these are done.
Rad [Visual C# MVP] - 18 Oct 2007 10:52 GMT
>> It's not glamorous, but a simple way is to perhaps  put the picture
>> box on a form, size it to be about the size of the form, set the
[quoted text clipped - 39 lines]
>handler so I could also close the form by hitting ESC. There's no way
>to close the form if neither of these are done.

Simple solutions to simple problems :)

--
http://bytes.thinkersroom.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.