From: Ajay Kalra on
Now things look better. I am not sure though what the problem could be.

--
Ajay Kalra [MVP - VC++]
ajaykalra(a)yahoo.com


"ccwork" <ccwork(a)discussions.microsoft.com> wrote in message
news:76F6C826-D4DC-4249-8C3A-B256548922F8(a)microsoft.com...
> Sorry. Actually the code is:
> class MyWnd:public CFrameWnd
> {
> public:
> MyWnd()
> {
> Create(NULL,"MFC Tutorial Part 1 CoderSource Window");
> 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;
> }
>
> "ccwork" wrote:
> > "Ajay Kalra" wrote:
> >
> > > Unless you are doing it somewhere else, you have not created the
window
> > > represented by MyWnd *wnd. You have created an object on the heap but
not
> > > yet called wnd->Create or CreateEx etc.
> >
> > I did. In the InitInstance. Please read again.
> > class MyApp:public CWinApp
> > {
> > MyWnd *wnd;
> > public:
> > BOOL InitInstance()
> > {
> > AfxEnableControlContainer();
> > wnd=new MyWnd();
> > }
> > }
> >
> > > --
> > > Ajay Kalra [MVP - VC++]
> > > ajaykalra(a)yahoo.com
> > >
> > >
> > > "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?
> > >
> > >
> > >


From: ccwork on
"Ajay Kalra" wrote:

> Now things look better. I am not sure though what the problem could be.
>
>
> Ajay Kalra [MVP - VC++]
> ajaykalra(a)yahoo.com

Oh no ... do you know where I can find sample code of using
createcontrol()?

>
> "ccwork" <ccwork(a)discussions.microsoft.com> wrote in message
> news:76F6C826-D4DC-4249-8C3A-B256548922F8(a)microsoft.com...
> > Sorry. Actually the code is:
> > class MyWnd:public CFrameWnd
> > {
> > public:
> > MyWnd()
> > {
> > Create(NULL,"MFC Tutorial Part 1 CoderSource Window");
> > 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;
> > }
> >
> > "ccwork" wrote:
> > > "Ajay Kalra" wrote:
> > >
> > > > Unless you are doing it somewhere else, you have not created the
> window
> > > > represented by MyWnd *wnd. You have created an object on the heap but
> not
> > > > yet called wnd->Create or CreateEx etc.
> > >
> > > I did. In the InitInstance. Please read again.
> > > class MyApp:public CWinApp
> > > {
> > > MyWnd *wnd;
> > > public:
> > > BOOL InitInstance()
> > > {
> > > AfxEnableControlContainer();
> > > wnd=new MyWnd();
> > > }
> > > }
> > >
> > > > --
> > > > Ajay Kalra [MVP - VC++]
> > > > ajaykalra(a)yahoo.com
> > > >
> > > >
> > > > "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?
> > > >
> > > >
> > > >
>
>
>
From: ccwork on
Can I send you the whole program that you can have more information?

"Ajay Kalra" wrote:

> Now things look better. I am not sure though what the problem could be.
>
> --
> Ajay Kalra [MVP - VC++]
> ajaykalra(a)yahoo.com
>
>
> "ccwork" <ccwork(a)discussions.microsoft.com> wrote in message
> news:76F6C826-D4DC-4249-8C3A-B256548922F8(a)microsoft.com...
> > Sorry. Actually the code is:
> > class MyWnd:public CFrameWnd
> > {
> > public:
> > MyWnd()
> > {
> > Create(NULL,"MFC Tutorial Part 1 CoderSource Window");
> > 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;
> > }
> >
> > "ccwork" wrote:
> > > "Ajay Kalra" wrote:
> > >
> > > > Unless you are doing it somewhere else, you have not created the
> window
> > > > represented by MyWnd *wnd. You have created an object on the heap but
> not
> > > > yet called wnd->Create or CreateEx etc.
> > >
> > > I did. In the InitInstance. Please read again.
> > > class MyApp:public CWinApp
> > > {
> > > MyWnd *wnd;
> > > public:
> > > BOOL InitInstance()
> > > {
> > > AfxEnableControlContainer();
> > > wnd=new MyWnd();
> > > }
> > > }
> > >
> > > > --
> > > > Ajay Kalra [MVP - VC++]
> > > > ajaykalra(a)yahoo.com
> > > >
> > > >
> > > > "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?
> > > >
> > > >
> > > >
>
>
>
From: Ajay Kalra on
> Can I send you the whole program

No. Discussing it here with others is a far better option and I dont have
time to go deeper than this on any issue.

--
Ajay Kalra [MVP - VC++]
ajaykalra(a)yahoo.com




From: ccwork on
I am sorry.
But the application does not have document/view class. Will this be the cause?

"Ajay Kalra" wrote:

> > Can I send you the whole program
>
> No. Discussing it here with others is a far better option and I dont have
> time to go deeper than this on any issue.
>
> --
> Ajay Kalra [MVP - VC++]
> ajaykalra(a)yahoo.com
>
>
>
>
>