Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subclassing to intercept system messages?

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
0
0
GB
Can subclassing be used to intercept system-wide messages such as changes to the system colours, changes to the contents of Clipboard etc?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
You need to intercept WM_SYSCOLORCHANGE message which is sent when a system color is changed.

To detect various other system notifications, look for WM_SETTINGCHANGE message. This message covers a wide variety of system events, from changing desktop wallpaper to modifying environment variables.

To monitor the clipboard and get notified when its contents change, you need to register your application window as a "clipboard viewer" window. See the following thread for details.
thread222-576513
 
Sorry Hypetia, I didn't quite explain it right.

When you subclass (as I understand it) you specify the hWnd of the object from which you want to intercept the messages, so what do you use in place of the hWnd if you want to get system messages?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
It is your application window which receives system messages. You do not need to create a special window or use a special hWnd for this purpose.

Just subclass your application's main window as above messages are sent to top-level windows only. Windows will not send these messages to, a picturebox, for instance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top