Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - Problems getting calendar to exit properl
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problems getting calendar to exit properl

 Post Reply Post Reply
Author
Message
RolandoE. View Drop Down
Groupie
Groupie
Avatar

Joined: 19 May 2003
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote RolandoE. Quote  Post ReplyReply Direct Link To This Post Topic: Problems getting calendar to exit properl
    Posted: 03 October 2005 at 8:37am

Hi,

I've tried everything I can think about. I even copied code from another proyect which uses the Calendar Control successfully and I am still having some problems with the following code.   The program comes up and everything runs fine. There is no code to post events or anything like this. All I am doing right now is displaying the Calendar control and linking it with the Date Picker control via the CXTPCalendartController class.

Within CDlgAgenda::OnInitDialog()...

// Create Calendar Control Window
if (!m_wndCalendar.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BOR DER, CRect(0,0,0,0), this, 333))
return -1;

// Attach Date Picker and Calendar Control to Calendar Controller
// Causing error at program close!!
m_CalendarController.SetCalendar(&m_wndCalendar);
m_CalendarController.SetDatePicker(&m_wndDatePicker);
m_wndCalendar.SwitchActiveView(xtpCalendarMonthView);

The problem I am having is when the application exits I am getting an error within CCmdTarget::~CCmdTarget()!! Tracing back I get to CWnd::~CWnd(), CXTPCalendarControl::~CCalendarControl() then finally CDlgAgenda::~CDlgAgenda() (This is where the calendar control is found).

The weird part is that I do not have this problem if I comment out the following line:

m_CalendarController.SetCalendar(&m_wndCalendar);

Any ideas? Do you need more information? I already tried creating the calendar control within OnCreate().

Thanks for the help.

Rolando

Rolando E. Cruz-Marshall
Back to Top
RolandoE. View Drop Down
Groupie
Groupie
Avatar

Joined: 19 May 2003
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote RolandoE. Quote  Post ReplyReply Direct Link To This Post Posted: 03 October 2005 at 5:30pm

More on previous message!!!

I do not know if this matters at this point but I only get the above mentioned behaviour in DEBUG mode only!

Rolando E. Cruz-Marshall
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2005 at 1:33am
Rolando,

It looks like an assertion could be caused because a destructor for the Calendar is called before the destructor for Controller.

Try to Set calendar and date picker to NULL in your dialog destructor:

CDlgAgenda::~CDlgAgenda
{
    m_CalendarController.SetCalendar(NUL L);
    m_CalendarController.SetDatePicker(N ULL);
}


--
WBR,
Serge
Back to Top
RolandoE. View Drop Down
Groupie
Groupie
Avatar

Joined: 19 May 2003
Location: United States
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote RolandoE. Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2005 at 7:26am
Thanks It worked!!
Rolando E. Cruz-Marshall
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.223 seconds.