CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Apr 2007
    Posts
    68

    VB.Net and Screensaver problem

    Morning All

    I have a Visual Basic Application that I have created in Visual Studio 2005. This application is a data logging screen that displays running and downtime details of machines on my production.

    The company has now enforced a Screen Saver policy which enables after 15 minutes. This now defeats the purpose of my screen as the operators should see real time data instead of having to go to the PC afre 15 minutes to unlcok the PC (Windows 7) to see the screen.

    Is there anyway that I can have the screen still shown even when the screen saver is active, eg make it the screen saver or something along those lines?

    Regards

    Douglas Bell

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: VB.Net and Screensaver problem

    AFIK .. You can override the screensaver timer by using the sendkeys to make the system belive the user is still active on the system. You could also disable the sreensaver on startup and enable it on exit via code...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Apr 2007
    Posts
    68

    Re: VB.Net and Screensaver problem

    Hi GremlinSA

    The sendkeys option sounds good unfortuantly this basically disables the screen saver completly as the Data screen is active all the time, IT Security would not go for this as if no user is present at the PC it must be locked. Disabling the screensaver at startup is not an option as the local user has no rights to the Screen Saver as it is applied via a GPO and again it would be in breech of IT security., Is there such a thing as a completly transparent screen saver?

    Regards

  4. #4
    Join Date
    May 2002
    Location
    Boston
    Posts
    67

    Re: VB.Net and Screensaver problem

    Hi,

    If the user's have some rights to the registry you can change the screensaver settings here..

    use Microsoft.Win32.Registry


    HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop


    Name ScreenSaveTimeOut
    Type REG_SZ
    Value 900

    900 = 15min

    or if that's not an option, what if you set up a timer in your app to save multiple images of the main form or objects in the form to a bitmap or jpeg
    that get saved to the slideshow folder. Then setup the screensaver to the slideshow setting. You can set the slideshow to update every 6 seconds. At least the user can see an updated display of the chart or data that's on your main form.

    Just a thought.

    Curt

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB.Net and Screensaver problem

    Have IT Security run your program as a service
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: VB.Net and Screensaver problem

    Even as a service, the screen saver settings would override it.

    Curt's idea would most probably be your best option

    I think I remember ( My brain is not what it used to be ) That you can use the SendMessage API and send a particular message to stop the screensaver from coming up - I'll have to look that up - Google is HUGE.

    There is also another API, I did something some time ago.... Come to think of it, that managed the Power off settings.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Talking Re: VB.Net and Screensaver problem

    Aha! I knew I had it on my system!!

    You can use the SystemParametersInfo API. You could use it with the SPI_SETSCREENSAVETIMEOUT constant. So, if you do something like this :


    Code:
    Imports System.Runtime.InteropServices
    Imports Microsoft.Win32         'for system events
    
    Public Class Form1
    
        'This function queries or sets system-wide parameters, and updates the user profile during the process.
    
        <DllImport("user32", EntryPoint:="SystemParametersInfo", CharSet:=CharSet.Auto, SetLastError:=True)> _
          Private Shared Function SystemParametersInfo(ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
        End Function
        Private Const SPI_SETSCREENSAVETIMEOUT As Int32 = 15
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            'Sets the screen saver time-out value to the 
            'value of the uiParam parameter. This value is the amount of time, 
            'in seconds, that the system must remain idle before the screen saver activates. 
            'So, if you set it 30, it will suspend the screensaver & Power Off features for 30 minutes
            SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 30, 0, 0)
    
        End Sub
    
    
    End Class
    it will suspend the screensaver & Power Off features for 30 minutes

    I hope this helps.

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB.Net and Screensaver problem

    Sounds to me like your best bet would be to create a screen saver that talks to your program and displays results as a screen saver so that when the screen saver kicks in it will take over the job of displaying your data to the users while still allowing the system to be locked.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB.Net and Screensaver problem

    Could be a punishable offense. It was where I worked. One screen saver for the system that locked when THEY wanted it.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB.Net and Screensaver problem

    I would not see anything wrong with creating a screen saver that displays useful information. The only purpose for a screen saver is to prevent burn in on a monitor combined with the optional locking feature. To most companies it would not matter what the screen saver was so long as it is not malicous or vulgar or somehow inappropriate.
    Always use [code][/code] tags when posting code.

  11. #11
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB.Net and Screensaver problem

    Same with desktop backgrounds. Sounds innocent, until someone gets a 900MB picture of whatever the current theme was. They sent it to everyone and clogged up the server with copies.

    People were bringing software from home, and installing it (violating licenses). Something had to be done
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  12. #12
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB.Net and Screensaver problem

    I really do not see how that relates to the subject at hand?
    Always use [code][/code] tags when posting code.

  13. #13
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB.Net and Screensaver problem

    Any software falls into the same 'rogue' category
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  14. #14
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB.Net and Screensaver problem

    I could be wrong but it sounds like the software in question here is intended for in house use.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured