Solved

Using .jpg as screensaver in windows application

Posted on 2009-05-14
6
219 Views
Last Modified: 2012-05-07
Hi experts,

          I have a .jpg file, which i want to show as screen saver using a
C# windows application [VS 2008].
          Another requirement is Hot Keys are not allowed to deactivate
the screen saver.

          I have no idea about this. Please help me on this....
0
Comment
Question by:srk1982
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:xnatex21
Comment Utility
What's the real question here?

You want a screensaver with a certain jpg? Or you've written a C# program (odd b/c I always thought of C# was used for client/server stuff) that is a screen saver program and you need help with it?
0
 

Author Comment

by:srk1982
Comment Utility
Hi xnatex21,

         I have a windows application coded in c#, when the user is
inactive for 30 seconds, i want to show a .jpg file in my application
folder as screensaver.

thanks for your immediate responce...
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
Create a new form and set its image property to the .jpg you desire (you can import a .jpg as a resource). Set the properties of your new form as such:
////////////////////////////////////////////////////////////////////

// New Form Code

////////////////////////////////////////////////////////////////////

public Form1()

{

    InitializeComponent();

    this.FormBorderStyle = FormBorderStyle.None;

    this.WindowState = FormWindowState.Maximized;

    this.MouseMove += Form1_MouseMove;

}
 

private void Form1_MouseMove(object sender, MouseEventArgs e)

{

    this.Close();

}
 

////////////////////////////////////////////////////////////////////

//  From main application

////////////////////////////////////////////////////////////////////

// After 30 seconds elapses (use a timer)
 

public void SomeFunction()

{

    (new ScreenSaverForm()).ShowDialog();

}

Open in new window

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
My mistake:  The MouseMove handler should be on the picturebox, not the form. See below.
public Form1()

{

    InitializeComponent();

    this.FormBorderStyle = FormBorderStyle.None;

    this.WindowState = FormWindowState.Maximized;

    this.Size = new Size(this.Size.Width * 2, this.Size.Height);

    this.pictureBox1.MouseMove += pictureBox1_MouseMove;

}
 

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

{

    this.Close();

}

Open in new window

0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
Sorry I didn't include this before (I just re-read your question). As far as preventing hotkeys, you can handle the KeyDown event of the form and check if Alt is pressed:
////////////////////////////////////////////////////////////////////

// Everything together

////////////////////////////////////////////////////////////////////

public Form1()

{

    InitializeComponent();

    this.FormBorderStyle = FormBorderStyle.None;

    this.WindowState = FormWindowState.Maximized;

    this.Size = new Size(this.Size.Width * 2, this.Size.Height);

    this.pictureBox1.MouseMove += pictureBox1_MouseMove;

    this.KeyDown += new KeyEventHandler(Form1_KeyDown);

}
 

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

{

    this.Close();

}
 

private void Form1_KeyDown(object sender, KeyEventArgs e)

{

    if (e.Alt)

        e.Handled = true;

}

Open in new window

0
 

Author Comment

by:srk1982
Comment Utility
Hi kaufmed,

     Thanks for your prompt reply. I am in halfway.
     For now screen saver is disappering when there is a mouse movement.
     I also want to functionality for the screen saver to vanish in case there
     is a key press in keyboard except hot keys.

Thanks....
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now