0

I do this exact thing for both edit and richedit but for the latter there is an access violation, why? The same thing happens when done for tabctrl too. What am I doing wrong? How can I get it to work?

WNDPROC OriginalProc;

LRESULT CALLBACK MyProc(HWND h, UINT m, WPARAM w, LPARAM p)
{
return OriginalProc (h, m, w, p);// access violation for common controls
}

// elsewhere 
HWND h = CreateWindow(....)
OriginalProc = (WNDPROC)SetWindowLong(h, GWL_WNDPROC, (LONG)MyProc);

I am using vc++ 6.

Thanks in advance.

  • Have you perhaps forgotten to call [`InitCommonControlsEx()`](http://msdn.microsoft.com/en-us/library/bb775697%28VS.85%29.aspx). – David Heffernan Mar 27 '11 at 12:52

1 Answers1

5

You should not call OriginalProc directly; use CallWindowProc to call it instead.

Also, it's hard to tell from the sample you gave, but make sure OriginalProc is not being used by multiple windows. It looks here that it's a single global variable, but I'm guessing you're subclassing multiple windows.

tenfour
  • 36,141
  • 15
  • 83
  • 142