Create controls dynamically with ATL crashes in Windows Server 2016

  • Thread starter Thread starter Suman GVS
  • Start date Start date
S

Suman GVS

Guest
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.

// initialize ATL ActiveX hosting

AtlAxWinInit();

// create the control (will fail if not registered) IDC-> Of a Picture cotrol

CWindow dlgWin = GetDlgItem(IDC_SELECT_GRID_HOST_FOL); // get host window

m_grid.CreateInstance(__uuidof(FiltFolder)); //FiltFolder is a Composite Control

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);


// attach the control to the host window

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

Continue reading...
 
Back
Top