Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - CXTPDatePickerControl deconstructor causing assert
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPDatePickerControl deconstructor causing assert

 Post Reply Post Reply
Author
Message
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Topic: CXTPDatePickerControl deconstructor causing assert
    Posted: 22 August 2006 at 3:31pm
I am receiving a Debug Assertion Failed on line 1013 in the microsoft file wincore.cpp when I run the following code:
 
 
void CMyDlg::OnBtnCalendar()
{
     COleDateTime oDate;
     CRect oRect;
     CString oEquationDate;
     CXTPDatePickerControl oDatePicker;
     CXTPWindowRect oPopUpRect(m_obtnCalendar.GetSafeHwnd());
   
     oDatePicker.GetMinReqRect(&oRect);
     oDatePicker.SetButtonsVisible(FALSE, FALSE);
     oRect.InflateRect(0 ,0, 4, 4);
     oRect.OffsetRect(oPopUpRect.right - oRect.Width(), oPopUpRect.bottom);
 
     if (oDatePicker.GoModal(oRect))
     {
         oDatePicker.GetCurSel(oDate);
         oEquationDate = oDate.Format(_T("\"%Y%m%d\""));
         AddText(oEquationDate, FALSE);
     }
}
 
The assertion does not happen until it hits the deconstructor for CXTPDatePickerControl.  It appears as though I can safely ignore the assertion but the boss has a problem with all debug assertions.  The first line in the deconstructor is:
XTPGetTopLevelWndMsgNotifier()->Unadvise(this);
Unadvise eventually calls VERIFY(DestroyWindow()) which then eventually makes its way down to line 1013 and asserts at ASSERT(m_hWnd == hWndOrig);
 
Has anyone else experienced this problem and/or been able to come up with a solution? 
 
thanks.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 22 August 2006 at 4:11pm
Hi,
What Toolkit version? What VC version?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Posted: 23 August 2006 at 8:00am
Originally posted by oleg oleg wrote:

Hi,
What Toolkit version? What VC version?
We're using ToolkitPro 10.2
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 August 2006 at 4:51pm
Hello,
I modified our DialogSample, added your code but don't see any problems.
please try it, do you see it on your computer?
 
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Posted: 25 August 2006 at 10:48am

The Calendar control is in a dialog that is loaded from an MFC extension DLL.  When we create the dialog off a pane on the apps main window we do not see the exception.  When we create the dialog from a button being pushed in a control on another dialog we get the exception.  The problem is getting to be a bit larger now because themes do not seem to be working correctly either.  I have played around with the Button sample project found in \\CodeJock\ToolkitPro\Samples\Controls\Button and can get everything to work correctly in there but when I copy the code line for line into our app it does not work correctly.  The themes never seem to work correctly.  When we use themes the backgroud colour of the button is always defaulting to the same colour as the dialog's background and the button borders are never being drawn.

 
The problem is not there in the DialogSample.zip, it works fine.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 August 2006 at 4:07pm

Hello,

May be you can modify attached sample/add MFC extension to show problem?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Enclaved Shadow View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2006
Location: Canada
Status: Offline
Points: 31
Post Options Post Options   Thanks (0) Thanks(0)   Quote Enclaved Shadow Quote  Post ReplyReply Direct Link To This Post Posted: 19 September 2006 at 10:59am
The problem was that MFC was using the incorrect window handle map when trying to destroy the window.  I added AFX_MANAGE_STATE(AfxGetAppModuleState()); to the top of the void CMyDlg::OnBtnCalendar()  method and it fixed the problem.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 September 2006 at 3:27pm
ok :)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
coffeeholic View Drop Down
Newbie
Newbie
Avatar

Joined: 16 March 2010
Location: Germany
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote coffeeholic Quote  Post ReplyReply Direct Link To This Post Posted: 16 March 2010 at 1:03pm

Hello,

in my case I also get a crash in XTPGetTopLevelWndMsgNotifier()->Unadvise(this);
 
I am using the Code in an ActiveX Control in an MFC Application. The call of the date time picker itself is in one of our librarys.
 
What if I leave all code with Advise() and Unadvise() out of the toolkit? I don't have a crash then anymore, but what features are missing or is the Datetime Picker functionalty given anyway? (I does work in this case in a short test)
 
All help in this topic would be helpful.
 
I forgot to mention that I tried to use AFX_MANAGE_STATE in Control too, but it didn't solve the problem.
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.203 seconds.