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
Solved

MDI Parent not getting wndproc messages

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 36
Sending receiving text messages in vb.net 15 48
vb.net and creating a class 5 20
VB.NET - Refactor Class per SOLID principles 2 17
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

856 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