|
-
October 22nd, 2007, 09:52 PM
#1
MFC missing a WM_ message I need
I have an MFC Dialog app that needs to handle WM_POWERBROADCAST so I can avoid standby mode.
In VS2005, I click my Dialog Class in Class View, then in the Class's Properties on the right, I click the Messages Button to view the available messages. There are many WM_ messages, but nothing to do with power. WM_POWERBROADCAST is not in the list.
How do I handle WM_POWERBROADCAST in MFC?
-
October 22nd, 2007, 10:35 PM
#2
Re: MFC missing a WM_ message I need
Handle it using ON_MESSAGE macro.
Or you may implement PreTranslateMessage.
-
October 22nd, 2007, 11:31 PM
#3
Re: MFC missing a WM_ message I need
ok thanks I'll remember that 
ps. I found an alternative way to avoid standby.
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
SetThreadExecutionState(ES_DISPLAY_REQUIRED);
-
October 25th, 2007, 09:24 AM
#4
Re: MFC missing a WM_ message I need
 Originally Posted by Anarchi
ok thanks I'll remember that
ps. I found an alternative way to avoid standby.
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
SetThreadExecutionState(ES_DISPLAY_REQUIRED);
That's very interesting. Thanks for sharing
-
October 25th, 2007, 01:48 PM
#5
Re: MFC missing a WM_ message I need
That makes a lot of sense, didn't know those were there! Cool!
Btw, if you ever need to use another message not already there, you should just be able to add it to your program's message map, then create the function to handle it.
-
October 25th, 2007, 02:53 PM
#6
Re: MFC missing a WM_ message I need
The API is really cool and useful if you need to control that in our application.
But, after search in MSDN I could not find anything to stop ScreenSaver from coming.
Hope someone could find API to supress Screen Saver, as Media Player does.
-
October 25th, 2007, 08:36 PM
#7
Re: MFC missing a WM_ message I need
SC_SCREENSAVE and WM_POWERBROADCAST are both sent when Windows calls its screensaver.
SC_SCREENSAVE is only sent to the application with current focus though, so you might have to use WM_POWERBROADCAST.
-
October 26th, 2007, 01:18 AM
#8
Re: MFC missing a WM_ message I need
I think this code also stops the screen saver but not 100% sure.
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
SetThreadExecutionState(ES_DISPLAY_REQUIRED);
If you call these functions every 30 seconds, it may do the trick.
Otherwise you can simply use this code to disable the SSaver (I hope its ok to post codeproject code here):
http://www.codeproject.com/system/disablescreensave.asp
-
October 26th, 2007, 02:11 AM
#9
Re: MFC missing a WM_ message I need
 Originally Posted by Anarchi
(I hope its ok to post codeproject code here):
It is absolutely okay - Brad won't mind
-
October 30th, 2007, 04:17 AM
#10
Re: MFC missing a WM_ message I need
 Originally Posted by Anarchi
I think this code also stops the screen saver but not 100% sure.
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
SetThreadExecutionState(ES_DISPLAY_REQUIRED);
If you call these functions every 30 seconds, it may do the trick.
No, these functions are not guaranteed to block screensavers.
 Originally Posted by MSDN
This function does not always stop the screen saver from executing when the computer is in use.
-
November 6th, 2007, 11:25 AM
#11
Re: MFC missing a WM_ message I need
You can set the power variables too, I'm not sure if you already tried that, and what total effect they'll have, I do know you can use them for blocking the screen going into standby mode, maybe it'll stop a screensaver?
SPI_SETPOWEROFFTIMEOUT
SPI_SETLOWPOWERTIMEOUT
Also, in the sysem parameters, you can set
SPI_SETSCREENSAVETIMEOUT.
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
|