We have a MMC Snap In Code built on VS 2005. The snap in has few property pages derived from CSnapInPropertyPageImpl<t>
Here is the code snippet for the class definition
class TTreeConfigPage02 : public CSnapInPropertyPageImpl<ttreeconfigpage02>
Here is the code snippet which works fine on Windows 10 but crashes at line
spHost->AttachControl(m_grid, m_wndGrid);
in Windows Server 2016. It immediately throws a error. The same ActiveX component when we add statically in dialog (On a dialog -> Right clink -> Insert ActiveX Component) works fine.
AtlAxWinInit();
CWindow dlgWin = GetDlgItem(IDC_SELECT_GRID_HOST_FOL);
m_grid.CreateInstance(__uuidof(FiltFolder));
ATLASSERT(m_grid != NULL);
RECT rcWind;
dlgWin.GetWindowRect(&rcWind);
ScreenToClient(&rcWind);
m_wndGrid.Create(m_hWnd, rcWind, NULL, WS_CHILD | WS_VISIBLE, 0, IDC_SELECT_GRID_FOL);
CComPtr<IAxWinHostWindow> spHost;
m_wndGrid.QueryHost(&spHost);
spHost->AttachControl(m_grid, m_wndGrid);
IUnknown* pUnk;
m_grid.QueryInterface(IID_IUnknown, &pUnk);
DispEventAdvise(pUnk);
Any thoughts on this as to why it is only failing in Win Server 16.
Thanks in advance
What I have tried:
Tried other option as well as mentioned in the link below. Nothing worked
https://jeffpar.github.io/kbarchive/kb/218/Q218442/