Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MDI Parent not getting wndproc messages

Posted on 2010-09-23
3
Medium Priority
?
518 Views
Last Modified: 2012-08-13
I have an MDI application where I need to trap the start of the screen saver. I have set up an ifiltermessage for the parent form to check for the sc_screensaver message. But, it only receives the message if the MDI parent has focus.

The MDI children are other apps that I set the parent hwnd to my MDI parent... So, I cannot add code to these MDI children.

My only hope is to find a means of globally reading messages for my app, even when the parent window is not the top window (only the top window of an application will receive messages).

If you can help, I would be grateful.
0
Comment
Question by:straubtm
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 2000 total points
ID: 33753867
The message falls into the range WM_SYSCOMMAND so only the top level window will get the message. You would have to use DLL injection to recieve that message regardless of which window would be top level which would have to be done in C/C++
You can use an SystemParametersInfo()
http://msdn.microsoft.com/en-us/library/ms724947(VS.85).aspx
The messages you will want to use are as follows:
SPI_GETSCREENSAVETIMEOUT
SPI_GETSCREENSAVERRUNNING

Basically use SPI_GETSCREENSAVETIMEOUT to query the timeout value of the screen saver, setup a timer with that value and then use SPI_GETSCREENSAVERRUNNING to see if it's running. OR you can just call SPI_GETSCREENSAVERRUNNING every minute since the screen saver setting doesn't go below this value...

0
 
LVL 1

Author Closing Comment

by:straubtm
ID: 33764330
Awesome!  Thanks.
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 33771381
Hey just want to clarify something quickly about my comment.
<< OR you can just call SPI_GETSCREENSAVERRUNNING every minute since the screen saver setting doesn't go below this value >>
This is TRUE from looking at it from a user who enters into the control panel to set the screen saver delay setting. However it's possible by editing the registry or programmatically setting the screen saver to a value lower than one minute but not from the control panel screen saver settings area.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question