Solved

MDI Parent not getting wndproc messages

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now