Re: Crash in ActiveX control (developed in ATL) at design time in Visual C++ .Net

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks Alexander,

I shall give this a go.

Tuckers


"Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
news:OqqGRP4yFHA.2064@xxxxxxxxxxxxxxxxxxxxxxx
> You don't need to do anything in OnCreate. Check in the
> call stack who created this window and trace it up to the entry
> point into your DLL. You need to add AFX_MANAGE_STATE
> there. I simply assumed it is an interface method...
>
> --
> =====================================
> Alexander Nickolov
> Microsoft ex-MVP [VC], MCSD
> email: agnickolov@xxxxxxxx
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
>
> "Tuckers" <matt@xxxxxxxx> wrote in message news:di59e0$jeu$1@xxxxxxxxxxxxx
> > Thanks Alexander,
> >
> > I have tried this, though the method that it fails on is OnCreate and is
> > not
> > an interface. I have not yet added any interfaces to the control. It is
> > however crashing in AfxGetInstanceHandle().
> >
> > Tuckers
> >
> >
> > "Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
> > news:%232JE3SpyFHA.2652@xxxxxxxxxxxxxxxxxxxxxxx
> >> Do you have proper AFX_MANAGE_STATE macros used
> >> throughout your entry points (e.g. interface methods)?
> >>
> >> --
> >> =====================================
> >> Alexander Nickolov
> >> Microsoft ex-MVP [VC], MCSD
> >> email: agnickolov@xxxxxxxx
> >> MVP VC FAQ: http://www.mvps.org/vcfaq
> >> =====================================
> >>
> >> "Tuckers" <matt@xxxxxxxx> wrote in message
> >> news:di319q$924$1@xxxxxxxxxxxxx
> >> > Hi,
> >> >
> >> > We are developing an activeX control in ATL. It uses some COTS
software
> >> > written in MFC which requires a handle to a Cwnd. We can do this no
> >> > problem.
> >> > But when I hit the test button in Visual .Net 2003 it crashs the IDE.
> >> >
> >> > The offending code is
> >> >
> >> > LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
> >> > BOOL&
> >> > /*bHandled*/)
> >> > {
> >> >
> >> > RECT rc;
> >> > GetWindowRect(&rc);
> >> > rc.right -= rc.left;
> >> > rc.bottom -= rc.top;
> >> > rc.top = rc.left = 0;
> >> > m_ctlStatic.Create(m_hWnd, rc);
> >> > m_wnd = CWnd::FromHandle( m_ctlStatic.m_hWnd );
> >> > CRect rect( rc );
> >> > m_grid.CreateGrid(WS_CHILD|WS_VISIBLE,rect,m_wnd,1234); <-
> >> > **************crashs********
> >> > return 0;
> >> > }
> >> >
> >> >
> >> > The function it crashes in is AfxGetInstanceHandle(). Does anyone
have
> > any
> >> > ideas why this is happening. BTW it is fine in c#.
> >> >
> >> > Cheers
> >> >
> >> > Tuckers
> >> >
> >> >
> >>
> >>
> >
> >
> >
>
>



.



Relevant Pages