I need to replace one of the pre-defined window classes all across Windows. For example, I would like to replace the ‘EDIT’ class so that my own custom edit box is used whenever any Windows program calls CreateWindowEx with ‘EDIT’ as the class name argument.
How can I achieve this? Will a message hook help? I believe a message hook would impose too much of an overhead in this case. What are my alternatives?
What you’re asking for, i.e. changing the behaviour of the ‘EDIT’ class seen by other processes is a security risk and is not easy to implement: for example, http://msdn.microsoft.com/en-us/library/ms997565.aspx says, ‘Subclassing is allowed only within a process. An application cannot subclass a window or class that belongs to another process.‘
An architectural reason why it isn’t possible is that code is associated with a window class, your code is associated with your subclass, and your code isn’t easily available to (can’t be run from) other processes (except via hackish techniques such as DLL injection).
Might the
SetWindowsHookExAPI give you what you need, instead of subclassing?