|
-
Jan 11th, 2005, 10:33 AM
#1
Thread Starter
Addicted Member
Tricky
well my last thread abt disabling screen savers is resolved, i found a dll on net which has got the enable disable method, but this rises me with another problem,
on form load i disable the screen saver n on unload i enable it again, this goes fine as long the user closes the form itself, but for an abnormal termination like power failure e.t.c the screen saver would'nt get enabled again without the users knowledge ? wat to do
-
Jan 11th, 2005, 10:43 AM
#2
Re: Tricky
Well, the only way to tell if this will work is to code it, run the program and then just hit power switch on your PC to simulate a power outage. Anyway, the only way that I can think of to handle this would be to place your code in the Query_Unload event, and use the UnloadMode to detect what was happening. Here are the variables for this.
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'there are 5 unloadmode levels
Select Case UnloadMode
Case vbFormControlMenu 'UnloadMode 0
'form is being unloaded via the Close
'or by hitting the X in the upper right hand corner
'command from the System menu
Case vbFormCode 'UnloadMode 1
'Unload Me has been issued from code
Case vbAppWindows 'UnloadMode 2
'Windows itself is closing
Case vbAppTaskManager 'UnloadMode 3
'the Task Manager is closing the app
Case vbFormMDIForm 'UnloadMod 4
'an MDI child form is closing because
'its parent form is closing
End Select
End Sub
I guess I'd start with seeing if vbAppWindows would be the place to put it. Again, with a total power loss, I'm not sure if the code would execute, but it is worth a shot.
-
Jan 11th, 2005, 10:44 AM
#3
Addicted Member
Re: Tricky
Abnormal terminations are very tricky to account for, if it was me, i would write another small program - all it would do is enable the screen saver then terminate..
then your main program could add the smaller one to the startup registry file whenever it is run, and when you close down it removes it, so abnormal terminations would result in program number two running at next startup and restoring the screensaver..
(this may be a long way round though and i am also interested to know if there owuld be a better way..)_
hope i helped..
rob
-
Jan 11th, 2005, 10:54 AM
#4
Re: Tricky
When a user terminates an app from the task manager, the Querry_Unload never fires, so that could be considered an abnormal termination as well. To expand on makster246 solution, your main app could first store the state of the screen saver in the reg., then disable the screen saver, then fire a small service type app that monitors the main app, and when the main app closes, the sevice app then restores the state of the screen saver, deletes the key and exits. The sevice app could also be run at start up ( as makster246 said) and if the key is there, the it restores the screen save and exits, otherwise it just exits.
HTH
kevin
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Jan 11th, 2005, 11:03 AM
#5
Re: Tricky
 Originally Posted by kebo
When a user terminates an app from the task manager, the Querry_Unload never fires
If the app is terminated from the VB IDE, this is true, however, if a .Exe is running, QueryUnload does, in fact, fire. I just tested this. Put this code on a form
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbAppTaskManager Then
MsgBox "Yes I do fire"
End If
End Sub
Compile Project1.Exe - close the project, and execute Project1.Exe, then close it from TaskManager. You will see that message box.
-
Jan 11th, 2005, 11:14 AM
#6
Re: Tricky
its not firing for me
kevin
edit:
what Windows version are you on Hack?...I'm on XP home
Last edited by kebo; Jan 11th, 2005 at 01:11 PM.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Jan 11th, 2005, 12:53 PM
#7
Thread Starter
Addicted Member
Re: Tricky
well i agree, the vbTaskManager did not fire, i guess bcoz am using XP n u used some other platform
thinking on one of the suggestions., i initially thought the same, that i shud make a small script file n add it in registry who would run on startup everytime, all this script would do is to enable the screen saver n i guess this would be da best possible solution, does ne one of u ne idea how can i do dat ?
-
Jan 11th, 2005, 01:10 PM
#8
Re: Tricky
once you have a program to enable the screen saver, in the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run registry key, create the following new string value
Name: Enable Screen Saver
Type: REG_SZ
Data: complete path and name to your program.
WARNING! Backup your registry before making any changes, and don't blame me if it gets all fugged up.
kevin
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Jan 11th, 2005, 01:23 PM
#9
Re: Tricky
If there is a power outage then NO events get fired ANYWHERE in windows 
The whole lots just terminates.
makster246 has the right idea. You need a small app to enable your screen saver at runtime...However, when your app disables the screen saver you may want to write a value to the reg to say whether or not it was disabled before your app disables it or every time your PC boots it will enable the screen saver, even if the user doesn't want it 
Woka
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|