Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / October 2003



Tip: Looking for answers? Try searching our database.

Activate Windows Screensaver from Visual Basic

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Aldred - 16 Oct 2003 16:01 GMT
I wish to activate the Windows Screensaver if there is no activity on a Visual Basic form after 3 minutes.  Anyone know hoe to do this?  I have tried various examples on the net that use SendMessge but they don't seem to work.  I would really apprecate any help you can give.
Ken Halter - 16 Oct 2003 16:27 GMT
Here's one way... keep in mind that it's up to the user to setup a screensaver. I have
none so the code would fail.

Loading the Windows Screensaver from your VB Application
http://abstractvb.com/code/code826.asp

Signature

Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep it in the groups..

> I wish to activate the Windows Screensaver if there is no activity on a Visual Basic form after 3 minutes.  Anyone know hoe to do this?  I have tried various examples on the
net that use SendMessge but they don't seem to work.  I would really apprecate any help
you can give.
Tom Esh - 16 Oct 2003 17:22 GMT
>I wish to activate the Windows Screensaver if there is no activity on a Visual Basic form after 3 minutes.  Anyone know hoe to do this?  I have tried various examples on the net that use SendMessge but they don't seem to work.  I would really apprecate any help you can give.

I would not recommend it unless the sole purpose of your app is to run
the SS immediatley. Otherwise users are likely to find that sort of
behavior very disconcerting. Consider the case where the user is
working in Word or some other app and your app is running in the
background: the SS suddenly activates for no apparent reason. If your
app displays sensitive data that shouldn't be left on the screen for
anyone passing by to view, it would be better to hide or close your
app after 3 min rather than munging about with system-wide user
settings.

Anyhow, if you must...

Dim hwnd As Long
hwnd = GetForegroundWindow()
If hwnd = 0& Then
    hwnd = GetDesktopWindow()
End If
SystemParametersInfo SPI_SETSCREENSAVEACTIVE, 1&, ByVal 0&, _
        SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE
PostMessage hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, ByVal 0&

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
Laurent - 31 Oct 2003 20:57 GMT
Hi,

I think... You should have a look at this link :
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/s
upport/kb/articles/Q141/0/24.asp&NoWebContent=1


maybe, it will help you to start the "windows screen saver"... And, to
start the screen saver after 3 mn of no activity... try with a timer
(3000 ms) and count every timer_OnTimer() event, til you have 3mns (or
more!!!)

Nice coding, nice computing ;o)
Laurent

> I wish to activate the Windows Screensaver if there is no activity on a Visual Basic form after 3 minutes.  Anyone know hoe to do this?  I have tried various examples on the net that use SendMessge but they don't seem to work.  I would really apprecate any help you can give.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.