SIGN UP MEMBER LOGIN:    
ARTICLE

Screen Saver Using C#

Posted by Priyank Patel Articles | Windows Forms C# September 24, 2010
In this article I will show you how to make a screen saver by using c# windows form.
Reader Level:
Download Files:
 

Introduction: 

In this article I will show you how to make a screen saver by using c# windows form. It is not perfect screen sever as windows gives us but yes, it is little bit like that.

Steps:

1) Add a form in your application and make it form border style none. Set transparency key as form background color so it will make your form transparent.

1.gif

2) Put a timer control on your form and set it's interval as you want to display picture per millisecond on the computer screen.

3) Code behind

int x, y;
private void timer1_Tick(object sender, EventArgs e)
{          
    /*
    * here x & y are the variables  and below two line will put desktop's different
    * screen location in it.
    */
    x = Convert.ToInt32((Microsoft.VisualBasic.VBMath.Rnd()) * (this.ClientSize.Width));
    y =Convert.ToInt32((Microsoft.VisualBasic.VBMath.Rnd())*this.ClientSize.Height));
    /*
    * screenStart() is the function which works to display image at the different screen
    * location of the desktop      
    */
    screenStart();
}

//This is the function which is called in the time1_Tick even
private void screenStart()
{
    //Picturebox is created dyanamically
    PictureBox pbox = new PictureBox();
    //and then after it will display at different location
    pbox.Location = new Point(x, y);
    pbox.Height = 100;
    pbox.Width = 100;
    //picture is set to the picturebox from the Resources.
    pbox.Image = global::screensever.Properties.Resources.thank_you_blue_rose;
    pbox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
    //and at last control will added to the form
    Controls.Add(pbox);
}

//This the Form1_Keyup even from where you will exit from the application while its running.
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
    if (Keys.Escape == e.KeyCode)
    {
        this.Close();
    }
}

Login to add your contents and source code to this article
share this article :
post comment
 

i think u will show all step in your how to create your forms

Posted by vikram kadam Feb 01, 2011

Nicee

Posted by Prachi Deoupadhye Dec 05, 2010

thankx

Posted by Priyank Patel Oct 04, 2010
Posted by navatha rao Oct 02, 2010

thanx for suggestion.

Posted by Priyank Patel Sep 28, 2010
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Gauge for SharePoint
Become a Sponsor