From: ccwork on 25 Mar 2005 11:23 "Scott McPhillips [MVP]" wrote: > ccwork wrote: > > What's the meaning of "CWnd is already created"? I try to create the > > activeX control in the constructor of class derived from CWnd. And how do I > > know the m_hWnd has a value? > > A CWnd is merely a wrapper around a Win32 window. You can't do much > with a CWnd until it is connected to an actual Win32 window. The CWnd > is not a window until its Create function has been called. So its > m_hWnd value is NULL until after the Create function has been called. > > You cannot create a child window until after its parent window has been > created. You can create a child window in the parent's OnCreate message > handler, but you cannot create a child window in the constructor. > But as in InitInstance() I created the Wnd and the m_hWnd is there (message appears) but the control ""Could not place control" still appears. wnd->Create(NULL, "Hello"); if (wnd->m_hWnd) AfxMessageBox("m_hWnd is there"); wnd->test(); wnd is an object of CFrameWnd.
From: ccwork on 25 Mar 2005 23:23
No, the control is "mscal.calendar.7" which comes with Windows but not Visual C++ "Victor" wrote: > Take a look at MSDN article "PRB: Dynamic Creation of Redistributable > Control Fails" > (Article ID: Q151804) > Is it your case? > > Regards, > > Victor > > "ccwork" <ccwork(a)discussions.microsoft.com> wrote in message > news:7F11C3BC-5063-4246-8C82-DFB5788C07B7(a)microsoft.com... > > Hi, > > I try to insert ActiveX to my program as following: > > > > class MyWnd:public CFrameWnd > > { > > public: > > MyWnd() > > { > > CString strControlProgid; > > strControlProgid="mscal.calendar.7"; > > m_Control.DestroyWindow(); > > RECT rc; > > ::GetClientRect(m_hWnd,&rc); > > BOOL bStat=FALSE; > > bStat=m_Control.CreateControl(strControlProgid, "", > WS_VISIBLE, > > rc, > > this, 5000, NULL, FALSE, NULL); > > if (bStat == FALSE) > > { > > ::MessageBox (m_hWnd,"Error!!","Could not place > > control",MB_OK); > > } > > } > > private: > > CWnd m_Control; > > } > > class MyApp:public CWinApp > > { > > MyWnd *wnd; > > public: > > BOOL InitInstance() > > { > > AfxEnableControlContainer(); > > wnd=new MyWnd(); > > } > > } > > > > The error prompt "Error!! Could not place control" always appear. Anyone > > know what the problem? > > > |