• 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

    • "Samsung is shutting down yet another app used by millions" I will fix the clickbait title for you, free-of-charge: "Samsung shutting down it's Max VPN app"
    • Microsoft brings Planner Agent to all Microsoft 365 Copilot users by Ivan Jenic Image: Microsoft Microsoft has announced that Planner Agent in Microsoft 365 Copilot is now generally available to all users with a Microsoft 365 Copilot license. Planner Agent is the latest addition in the string of AI features that Microsoft is implementing across virtually all of its products. The agent lets you manage tasks through natural language prompts directly inside Microsoft 365 Copilot. You can create and update tasks, check priorities, and get insights about current entries without leaving the chat interface. The general availability release comes with a handful of new additions on top of what was available during the initial rollout. A new plan picker lets you search and filter your plans by name, then update task names, statuses, due dates, or priorities through the agent. There's also a goals bucket now, which lets you group tasks under specific goals. This builds on the Goals view, a feature that was introduced as part of the broader Planner refresh that rolled out earlier. Image: Microsoft | Planner Agent in Microsoft 365 Copilot All AI-generated plans and tasks are created in draft mode by default, so you can review and approve changes before anything goes through. This is actually a thoughtful safety feature, because trusting AI to handle all your tasks without a human in the loop is usually a recipe for disaster. Having tasks initially saved as drafts is the best possible middle ground. Microsoft also says that not all tasks are executed equally. Simple tasks get processed quickly, while more complex ones, like building a plan from a Word, Excel, or PowerPoint file, are handed to a more capable model. Microsoft says this approach delivers the best performance, but it could also help with usage management, as you won't have to waste tokens on performing simple tasks. Planner Agent is available now across Teams, Loop, SharePoint, and other Microsoft 365 apps for anyone on a Microsoft 365 Copilot subscription.
    • To be clear I'm anti trump, the bigger point is why review this game at all?
    • Trillion dollar Microsoft has to reduce spending by hurting more people. Good job Microsoft. Good Job Asha.
  • Recent Achievements

    • First Post
      Cosminus earned a badge
      First Post
    • 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
  • Popular Contributors

    1. 1
      +primortal
      493
    2. 2
      +Edouard
      191
    3. 3
      PsYcHoKiLLa
      124
    4. 4
      Steven P.
      86
    5. 5
      neufuse
      73
  • Tell a friend

    Love Neowin? Tell a friend!