• 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

    • Marshall Major V Bluetooth headphones are now up to 47% off on Amazon by Ivan Jenic The Marshall Major V in Midnight Blue is currently $89.99 on Amazon, down from $169.99. That's 47% off and $80 saved on a pair of wireless on-ear headphones from one of the most recognizable names in audio. The Major V is Marshall's take on a long-lasting everyday headphone. The headphones deliver 100+ hours of wireless playtime, which puts them in a completely different category from most Bluetooth headphones that hover around 30-40 hours. You’re charging this thing once a week at most, and with wireless charging supported, you don’t have to worry about additional cables. Marshall promises its signature sound profile, with strong bass, smooth mids, and clear highs. There’s a customizable M-button, which you can set to quickly access Spotify Tap, your EQ settings, or a voice assistant. The design is foldable and lightweight at 186 grams, so it’s easy to pack for travel. And finally, the faux leather finish gives the Major V a sleek, premium look. At $89.99, the Major V Midnight Blue is a genuinely strong buy for anyone who wants a reliable daily headphone without paying premium prices. It’s also worth mentioning that the Cream and Brown variants are also discounted to $89.99, though from a lower original price of $99.99. Marshall Major V Midnight Blue - $89.99 | 47% off on Amazon This Amazon deal is US-specific and not available in other regions unless specified. This is a first-party seller link (at the time of article publishing); ensure that you also purchase from a first-party seller link only. If you don't like it or want to look at more options, check out the previous deals that we have covered, OR you can also visit Amazon US deals page. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • +1 on XVI. I still use it. 
    • Age 16, old enough to get a full-time job, your own bank account, a passport, get married, even join the military and go to war. But talking to your friends on the internet? Oh hell no!
    • I remember when all games had demos; it was a normal thing, not a limited time promotion.
    • Forza Horizon 6 gets big bug-fixing and balancing update by Taras Buria Today, Playground Games released a big Forza Horizon 6 update with a long list of fixes, patches, and balancing tweaks that the studio promised earlier. Version 375.327 is now available on Steam, Microsoft Store, and Xbox, offering users improvements for AI, audio, design, performance, road discovery, upgrades, visuals, online play, and more. Some of the most notable changes in the Series 2 update include rebalanced drivatars, particularly their difficulty and race start behavior. As such, the game should be more balanced on higher difficulty levels, and AI cars should not shoot out when the race starts as if they have rocket boosters. Speaking of difficulty, developers nerfed Drag Tires physics for a more expected and realistic behavior. They are no longer the go-to option for record-breaking times in road racing, and all leaderboard entries with drag tires will be removed. Completionists will also be glad to get a new feature that lets you see road discovery percentage in each region, which should make discovering all roads easier while keeping it quite challenging and interesting (I spent quite a long time finding the last road). Festival Playlist is also getting some much-needed fixes, including patches for bugs that allowed completing Seasonal Jobs ahead of time or where weekly challenges would not unlock for some players. Developers will retroactively give reward points to all who could not complete all challenges due to these bugs. Other changes include changes to Horizon Play progression so that it is easier to reach Level 100, audio improvements on lower-spec devices, fixes for visual glitches, including pixelated smoke, and more. Developers also addressed the currently non-working Eliminator, an online mode gamers used to farm credits with a Hummer EV exploit. Playground Games plans to re-enable it soon. As a gesture of goodwill, players will get a free McLaren Sabre. Those who used the exploit will not be banned, but developers plan to roll back credits to a maximum of 10M for all who farmed credits using the exploit. You can find the complete changelog for the latest Forza Horizon 6 update here.
  • 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
      484
    2. 2
      +Edouard
      185
    3. 3
      PsYcHoKiLLa
      122
    4. 4
      Steven P.
      83
    5. 5
      neufuse
      73
  • Tell a friend

    Love Neowin? Tell a friend!