Click here to Skip to main content
15,436,489 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a static control on my dialog. I give the handle of the control to a third party DLL, which sends WM_SETTEXT messages directly to it.

However, now I find I might want to intercept that message and change the text. How do I do it?

What I have tried:

I've tried PreTranslateMessage in my dialog. All ON_NOTIFY and ON_REFLECT macros.

I think I might need a hook - but the documentation says I'm not allowed to modify the message using a hook?
Posted
Updated 24-May-21 21:55pm
v2

You can make a new class, derive it from CStatic, and let it handle all the messages you want it to and exactly how you want it to. As an example, see the CLabel class here : Extended Use of CStatic Class - CLabel 1.6[^]. That class is derived from CStatic and has facilities to change the font, colors, and other properties.
 
Share this answer
 
Comments
Maciej Los 25-May-21 3:59am    
5ed!
In addition to Rick's suggestion you can subclass a control which allows you to intercept all messages. See Subclassing Controls - Win32 apps | Microsoft Docs[^].
 
Share this answer
 
Comments
Maciej Los 25-May-21 3:59am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900