Solved

MDI Parent not getting wndproc messages

Posted on 2010-09-23
3
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

617 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