• 0

C# Screen saver?


Question

Recommended Posts

  • 0

Sorry for the problems in my code, i didnt even think that c# might not have a chr() function, i also keep forgetting about unicode and ansi (im to used to xp now), i have to start remembering that.

Also, i'm not at my house, so i dont have any code with me, but when i get home i'll upload my class, but i will paste some code from memory, this is just how to load my oo class

It's called ScreenSaverProcess because of an name conflict with another class

Starts a new class, this has to be called after the controls are added to the form or else you get a error

Dim ScreenSaver as ScreenSaverProcess = New ScreenSaverProcess("logon.scr",Panel1)

This gets the name

ScreenSaver.GetScreenSaverName()

This starts the configuation

ScreenSaver.StartScreenSaverConfig()

This starts the preview in the control specified in the new function

ScreenSaver.StartScreenSaverPreview()

This starts the screensaver full screen

ScreenSaver.StartScreenSaver()

This kill's the screensaver

ScreenSaver.KillScreenSaver()

Also, the GetScreenSaverName and New functions are overloaded, so you can specify a filename and directory for each function, e.g. ScreenSaver.GetScreenSaverName("logon.scr") or ScreenSaver.GetScreenSaverName("C:\Windows\System32","logon.scr") (Cause i dont have the code i cant remember if i append the trailing \ on the path)

Also, i hopefully will stop giving VB code soon, i want to start learning more of C#, i sort of know the syntax, but i would like to know more.

Edit: Thanks weenur, i didnt know that screensaver names cant be longer than 25 characters, i set it to 255 just to be safe (the code sample i looked at to fix the problems i was having (i had to fill the string with the 0 character first) was using 512 characters, so i dropped it down a bit)

Edited by The_Decryptor
  • 0

Ok, im home now, i changed my class to use DllImport so i can overcome the ANSI and Unicode stuff, and i limited the name of the screensaver to 25 characters, i think every thing is okay now

I have attached the whole ScreenSaver Shower Thingy to show off my class, and show how to use it.

ScreenSaver_Shower_Thingy.rar

  • 0

Thanks The_Decryptor :laugh: But I the code you gave is enough for now :)

Do you know how to change the time that Windows waits until it starts the screen saver? I tried to change ScreenSaveTimeOut which is in CurrentUser\\Control Panel\\Desktop in the registry, but it doesn't work. Do you know how can I change it ?

  • 0

I think it's a api call, i have a starter book on vb6 (it's old now though), it shows how to change the wallpaper and other things through a api call, so it might affect screen-savers to, ill start palying around with it now.

Also, the code was more for weenur, cause he said he wanted to see the oo class i based on his.

Edit: Yep, i was right, it's a api call, im just working on some code now.

Edited by The_Decryptor
  • 0

Ok, im done, i have code that can set and retrieve the time-out, i was going to post it earlier, but my browser crashed and i decided to change some stuff.

Declarations:

? ?<DllImport("user32", CharSet:=CharSet.Auto)> _
 ? ?Private Shared Function SystemParametersInfo(ByVal uAction As Integer, ByVal uParam As Integer, ByRef lpvParam As Integer, ByVal fuWinIni As Integer) As Integer
 ? ?End Function

 ? ?Private Const SPI_GETSCREENSAVETIMEOUT = 14
 ? ?Private Const SPI_SETSCREENSAVETIMEOUT = 15
 ? ?Private Const SPIF_UPDATEINIFILE = &H1
 ? ?Private Const SPIF_SENDWININICHANGE = &H2

Code:

? ?Public Function GetScreenSaverTimeOut() As Integer
 ? ? ? ?Dim lRet As Integer
 ? ? ? ?Dim lSeconds As Integer

 ? ? ? ?lRet = SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, lSeconds, 0)
 ? ? ? ?If lRet > 0 Then
 ? ? ? ? ? ?GetScreenSaverTimeOut = lSeconds / 60
 ? ? ? ?Else
 ? ? ? ? ? ?GetScreenSaverTimeOut = -1
 ? ? ? ?End If
 ? ?End Function

 ? ?Public Function SetScreenSaverTimeOut(ByVal NewValueInMinutes As Integer) As Boolean
 ? ? ? ?Dim lRet As Integer
 ? ? ? ?Dim lSeconds As Integer
 ? ? ? ?lSeconds = NewValueInMinutes * 60
 ? ? ? ?lRet = SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, lSeconds, Nothing, SPIF_UPDATEINIFILE + SPIF_SENDWININICHANGE)
 ? ? ? ?SetScreenSaverTimeOut = lRet <> 0
 ? ?End Function

It's pretty much self explanatory.

Also, yyy, if you want to see the similarities between vb.net and c#, i recommend you get a copy of .NET Reflector, it's a fully working Disassembler and De-compiler for .net, it allows you to choose from multiple languages, e.g. De-compile a vb app into c#, or vice-versa, it's really good.

Also 2, since you and weenur have been so good, and since im feeling generous, pm me if you:Dant a gmail account (I'm feeling generous because i got 6 invites today :D )

Edit: I'll need your names and e-mail address's to send the invites.

  • 0

Thanks :) There aren't enough smilies in here to show how happy I am. I just hope it will work for me :laugh: I convert it with SharpDevelop and most of the time it is good. Thanks for offering me another way.

Thanks also for the G-mail offer :laugh: but sorry - I am satisfy with my 10 MB account :laugh: 6 invites :o wow that's a lot. People sell those in E-bay :laugh: You are generous.

Thanks again.

  • 0

It should work, it's working flawlessly here (i put it in a loop that added 10 minutes to my time out then popped up a message box with the new time)

That's okay about the gmail account, im not actully using mine much (most of my e-mail still goes to hotmail) in case google shut's it down (it shouldn't happen, but i cant be to careful), but i probably wont sell them in ebay, i heard google is cracking down on people who sell them, and i dont want to cross google (they know my name and address :ninja: )

Also, with sharpdevelop. i was trying to convert my Certificate 3 teacher (who just happened to be a developer to) to it, i downloaded it, installed it on to his laptop just to find that there was no windows forms support (i.e. no gui), did i just miss something or is there no gui support for windows forms?

Also, the offer still stands weenur!

Edit: i wont be on for almost 24 hours from now, it's 2AM here and i have to go with my mum to the city (I'm in the suburbs) early tomorrow (she's getting a tattoo, and then we have to go baby-sit my cousin.)

Edited by The_Decryptor
  • 0

Tha main reson i would be using SharpDevelop is for Mono development (i heard a version exists), for Windows im using Visual Studio .NET Enterprise Architect 2003, it's fairly good :D

Anyway, at the moment im doing my dev stuff on a OSX machine with a mono port on it, and for any thing graphical or windows only, i use a vnc client to connect to the pc.

  • 0
Also, the code was more for weenur, cause he said he wanted to see the oo class i based on his.

I did? Ah, no matter. I appreciate that you've helped yyy in ways I couldn't. I'm always pressed for time, so I never get to give thorough examples.

I think I may take you up on that GMail invite. :) Thanks for that. (Y)

  • 0
Thanks, most of the time people are calling me stupid, but for somebody to say I'm great is a nice change

Also, weenur, i got your pm, i sent the invite to the bumpmapboy account, if you want me to send it to a different one just tell me.

You? Stupid? :no: :no: :no: You found the code for almost all of my program. You are really great :laugh: Good work :) Couldn't do it without you and weenur.

  • 0

Nobody is prefect. People can be wrong sometimes. Even I don't always right although I find the solutions eventually.

By the way, are you sure that your method of finding the screen savers name is ok? I can't see the names of some screen saver like the "Flying Windows" screen saver of Windows. Maybe I do something wrong.

  • 0
By the way, are you sure that your method of finding the screen savers name is ok? I can't see the names of some screen saver like the "Flying Windows" screen saver of Windows. Maybe I do something wrong.

It is working for every screensaver i try it on here, and i based the code on documentation from the msdn stuff (it just says that the name of the screensaver has to be the first string resource in the file) so it should work

But, i dont have the flying windows screensaver on xp, does it happen for any other screensavers?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Steam Next Fest returns with thousands of new demos to try out by Pulasthi Ariyasinghe Valve has been routinely kicking off demo festivals on Steam for years now, and the second drop of 2026 has just opened its doors. It's a great opportunity for any PC gamers to find some interesting games before they release. The June edition of Steam Next Fest is a week-long digital festival including gameplay slices from a large number of indie developers, though a few major publishers are involved this time too. Interested players can use the Next Fest hub page's various sorting and filtering options to easily sort through the hordes of demos available. The top buttons offer quick access to separate and important sorting options, including "By Genre, By Theme, By Feature," with each one offering more granular settings when clicked. At the same time, the built-in Steam tags system is also available below every page to discover new games more quickly. As always, logging in will also enable Steam gamers to utilize Valve's recommendation algorithms to find game demos they might like, specifically, depending on their past play and purchase histories. This time there is even a toggle now to swap between getting a random and personalized selection as Valve collects more data on the available demos. The Charts section is where you can find the most popular demos on the platform right now, offering up the most hyped titles in a simple list. Right at the kickoff, Mistfall Hunter, Empulse, Echoes of Aincrad, Onimusha: Way of the Sword, Over the Hill, Mortal Shell II, and more are trending. Expect this list to change as the week progresses. This edition of the Steam Next Fest is slated to end on June 22 at 10 AM PT. Valve's latest event is now open, and it can be accessed by going to the dedicated hub page here.
    • I lived and breathed MSN Messenger/Windows Live Messenger. Going to the mess.be website (still online with no changes since 2013) to download display pictures etc. I was a beta tester for Messenger Plus! and spent quite a lot of time on the MsgPlus! forums (a read-only copy is still online at https://shoutbox.menthix.net) Some old Neowin articles also https://www.neowin.net/news/messenger-plus-350/ good times but how time flies
    • Well i'll look into a docking station if needed and use that.    Normally i don't usually have all the drives connected at once,  usually once a month to sync the latest files, and then they go back in there storage area   
    • memories! completely forgot about alcohol 120%!!!! man this list just makes me think of all the exciting times! everything's become so sterilized these days. 
  • Recent Achievements

    • One Year In
      ThatGuyOnline earned a badge
      One Year In
    • Week One Done
      Jeroen Wilms earned a badge
      Week One Done
    • Week One Done
      rolfus earned a badge
      Week One Done
    • One Month Later
      Leroy Jethro Gibbs earned a badge
      One Month Later
    • Conversation Starter
      flexorcist earned a badge
      Conversation Starter
  • Popular Contributors

    1. 1
      +primortal
      506
    2. 2
      +Edouard
      200
    3. 3
      PsYcHoKiLLa
      127
    4. 4
      Steven P.
      82
    5. 5
      ATLien_0
      76
  • Tell a friend

    Love Neowin? Tell a friend!