Microsoft’s DSO Framer ActiveX Control makes it possible to embed Office documents in your own application. We’ve been using it in our .Net with more or less success.

One annoying bug, though, has been how the title of the Form hosting the DSOFramer got garbled if you disposed the DSOFramer OCX. I’ve finally tracked it down to a bug in CDsoFrameWindowHook::Detach(). Specifically, when the window hook restores the original window proc, it doesn’t pay attention to whether the form is a Unicode form, and always installs it as a non-unicode proc.

The fix is pretty simple. In dsofcontrol.cpp, replace the line that says:

// If this is the last control, we can remove the hook!
SetWindowLong(m_hwndTopLevelHost, GWL_WNDPROC, (LONG)(m_pfnOrigWndProc));

with the following:

// If this is the last control, we can remove the hook!
if (this->m_fHostUnicodeWindow)
SetWindowLongW(m_hwndTopLevelHost, GWL_WNDPROC, (LONG)(m_pfnOrigWndProc));
else
SetWindowLong(m_hwndTopLevelHost, GWL_WNDPROC, (LONG)(m_pfnOrigWndProc));