Solved

MDI Parent not getting wndproc messages

Posted on 2010-09-23
3
499 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sql server insert 13 46
Checking a checkbox based on SQL DataReader boolean value in ASP.NET(VB) 2 45
RLDC Reporting in Visual studio 11 42
Generate Numbers in JQuery file 11 72
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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