Help disabling Windows Screensaver |
Author: |
Message: |
Salem
Senior Member
Posts: 769 Reputation: 16
37 / /
Joined: May 2004
|
O.P. Help disabling Windows Screensaver
Hi There
I'm seriously looking for help on how to disable the windows screensaver whenever the application i created is opened and then have the screensaver enabled again when my application is closed. My program is being written in Visual Basic. I'm fairly new to VB (hav only been programming with it for about a year now) so any help will be appreciated, although the more detailed the help the better (would be better if visual basic code is provided).
For the person who provides the most effective VB code i'd be willing to reward you with a Gmail (1GB) e-mail account, and i'd give you credit in my program (the program will be publically available on the web in 2005). You will also be given beta testing privilages for the product this code will go towards
Thanx in advance
EDIT: Id also like to notify everyone here that I've posted the same request on another forum offering the same reward. Whichever one works first and the best will receive the reward. The winner will be informed by PM.
edited by: RileyM at 10:29 (GMT) on New Years' Eve 2004. Reason for editing: to notify posters that this request was posted at another forum as well
This post was edited on 12-31-2004 at 10:32 AM by Salem.
Was i Helpful?[/url]
|
|
12-30-2004 07:03 PM |
|
|
Mike
Elite Member
Meet the Spam Family!
Posts: 2795 Reputation: 48
32 / /
Joined: Mar 2003
Status: Online
|
RE: Help disabling Windows Screensaver
Try this
Put this on the top of the form code
code: '<<< CONSTANTS >>>
Private Const SPI_SETSCREENSAVEACTIVE As Long = 17
Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPIF_SENDWININICHANGE = &H2
'<<< DECLARES >>>
Private Declare Function SystemParametersInfo _
Lib "user32" _
Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam As Long, _
ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
To enable/disable the screensaver:
code: Dim lRet As Long
lRet = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, ByVal 0, SPIF_UPDATEINIFILE)
Change the bolded part to 0 if you want to disable it and to 1 if you want to enable it
|
|
12-30-2004 10:37 PM |
|
|
Salem
Senior Member
Posts: 769 Reputation: 16
37 / /
Joined: May 2004
|
|
12-30-2004 10:56 PM |
|
|
Mike
Elite Member
Meet the Spam Family!
Posts: 2795 Reputation: 48
32 / /
Joined: Mar 2003
Status: Online
|
RE: Help disabling Windows Screensaver
Yeah, you put this code in the form_load event, command1_click event etc
|
|
12-30-2004 10:57 PM |
|
|
Salem
Senior Member
Posts: 769 Reputation: 16
37 / /
Joined: May 2004
|
O.P. RE: RE: Help disabling Windows Screensaver
quote: Originally posted by Mike2
Yeah, you put this code in the form_load event, command1_click event etc
oh, so i must put it on a button, not form load. and the other code also in the button?
Was i Helpful?[/url]
|
|
12-30-2004 11:01 PM |
|
|
DJeX
Veteran Member
Posts: 1138 Reputation: 11
– / / –
Joined: Jul 2003
|
RE: Help disabling Windows Screensaver
Put this code above all other code in the form. (very top)
code: '<<< CONSTANTS >>>
Private Const SPI_SETSCREENSAVEACTIVE As Long = 17
Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPIF_SENDWININICHANGE = &H2
'<<< DECLARES >>>
Private Declare Function SystemParametersInfo _
Lib "user32" _
Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam As Long, _
ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Now you can put this code in the form_load:
code: Dim lRet As Long
lRet = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, ByVal 0, SPIF_UPDATEINIFILE)
This post was edited on 12-30-2004 at 11:08 PM by DJeX.
|
|
12-30-2004 11:07 PM |
|
|
Salem
Senior Member
Posts: 769 Reputation: 16
37 / /
Joined: May 2004
|
O.P. RE: RE: Help disabling Windows Screensaver
quote: Originally posted by DJeX
Put this code above all other code in the form. (very top)
code: '<<< CONSTANTS >>>
Private Const SPI_SETSCREENSAVEACTIVE As Long = 17
Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPIF_SENDWININICHANGE = &H2
'<<< DECLARES >>>
Private Declare Function SystemParametersInfo _
Lib "user32" _
Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam As Long, _
ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Now you can put this code in the form_load:
code: Dim lRet As Long
lRet = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, ByVal 0, SPIF_UPDATEINIFILE)
sorry if im a bit confused. when u say put it at right at the top of them form do you mean on a button? And put the dim IRet part on form load?
dont i need to put anything in a module?
RileyM
This post was edited on 12-30-2004 at 11:17 PM by Salem.
Was i Helpful?[/url]
|
|
12-30-2004 11:17 PM |
|
|
DJeX
Veteran Member
Posts: 1138 Reputation: 11
– / / –
Joined: Jul 2003
|
RE: Help disabling Windows Screensaver
Humm well now that I look at his code I see its a bit dodgy.
I attached a VB project that will enable or disable the screen saver with command buttons.
It can easly be edited to enable or disable on form load.
Give it a try.
Attachment: screen saver disable enable.zip (1.55 KB)
This file has been downloaded 216 time(s).
|
|
12-30-2004 11:24 PM |
|
|
Salem
Senior Member
Posts: 769 Reputation: 16
37 / /
Joined: May 2004
|
O.P. RE: RE: Help disabling Windows Screensaver
quote: Originally posted by DJeX
Humm well now that I look at his code I see its a bit dodgy.
I attached a VB project that will enable or disable the screen saver with command buttons.
It can easly be edited to enable or disable on form load.
Give it a try.
Thanks for that. I've put it in my program and havent received any error messages yet . I'm knackered, so wil test it tomorrow and will get back to you. If everything works i'll PM you to sort out you Gmail invite and how you like to be credited, in my program.
Thnx agen
RileyM
Was i Helpful?[/url]
|
|
12-30-2004 11:53 PM |
|
|
Salem
Senior Member
Posts: 769 Reputation: 16
37 / /
Joined: May 2004
|
O.P. RE: RE: Help disabling Windows Screensaver
quote: Originally posted by DJeX
Humm well now that I look at his code I see its a bit dodgy.
I attached a VB project that will enable or disable the screen saver with command buttons.
It can easly be edited to enable or disable on form load.
Give it a try.
Sorry it did not work.
i created menu a menu where it will allow the user to select whether he/she wants the screensaver disabled.
i've placed the code behind the Enabled button in nthe menu's click event when i want to enable the screensaver and i placed the code behind the disable button on the menu when it should disable the screensaver. unfortunately, both wehn the menu should enable and disable the screensaver the screensaver was displayed anyway.
any ideas?
RileyM
Was i Helpful?[/url]
|
|
12-31-2004 10:16 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|