Custom Control in a DLL
-
I have created a custom control in a DLL and it works perfectly when used in a dialog box or property page. However, if I try to use the control in a view window, I get infinite recursion. The following window procedure is straight out of David Kruglinksi: LRESULT CALLBACK AFX_EXPORT OCTimeslotCtrlWndProc(HWND h_wnd,UINT message,WPARAM w_param,LPARAM l_param) { CWnd* p_wnd; p_wnd = CWnd::FromHandlePermanent(h_wnd); if (p_wnd == NULL) { // // first-time; a new window has been created // p_wnd = new OCTimeslotCtrl; p_wnd->Attach(h_wnd); ASSERT(p_wnd == CWnd::FromHandlePermanent(h_wnd)); } ASSERT(p_wnd->m_hWnd == h_wnd); LRESULT l_res = AfxCallWndProc(p_wnd,h_wnd,message,w_param,l_param); return (l_res); } As I said, this works fine when the control is used in a dialog box. However, when used in a view, the call to AfxCallWndProc simply indirectly recurses back to OCTimeslotCtrlWndProc. A stack overflow immediately occurs. Does anyone know how to get a custom control in a DLL to work everywhere?