- m_oldParentWndProc = (WNDPROC)::SetWindowLong
- (
- hwnd,
- GWL_WNDPROC,
- (LONG)FindReplaceWindowProc
- );
-
- // save it elsewhere to access it from FindReplaceWindowProc()
- (void)::SetWindowLong(hwnd, GWL_USERDATA, (LONG)m_oldParentWndProc);
+
+ // check that we don't subclass the parent twice: this would be a bad idea
+ // as then we'd have infinite recursion in wxFindReplaceWindowProc
+ if ( !wxCheckWindowWndProc((WXHWND)hwnd, (WXFARPROC)wxFindReplaceWindowProc) )
+ {
+ // set the new one and save the old as user data to allow access to it
+ // from wxFindReplaceWindowProc
+ m_oldParentWndProc = wxSetWindowProc(hwnd, wxFindReplaceWindowProc);
+
+ wxSetWindowUserData(hwnd, (void *)m_oldParentWndProc);
+ }