tags:

views:

108

answers:

1

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?

+1  A: 

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 SetWindowsHookEx API give you what you need, instead of subclassing?

ChrisW
Would it be possible to replace the DLL where EDIT is defined with one of my own, provide my own definition of EDIT while forwarding all other calls to the original DLL?
Vulcan Eager
ChrisW
The URI was truncated: it was meant to link to topics in the microsoft.public.win32.programmer.* newsgroups which mention the term 'shim' and/or 'shimeng'.
ChrisW
Why I want to do this: As an example, suppose I want to provide a better textbox with column markers or a vi mode... just an idea for a pet project.
Vulcan Eager