|
|
|
Register •
FAQ
• Search • Login
|
|
Page 1 of 1
|
[ 5 posts ] |
|
| Author |
Message |
|
mse61
Joined: Wed Apr 18, 2001 7:01 am Posts: 6 Location: /dev/null
|
 MFC Problems
I'm working on an MFC application to brush up on my programming skill before i head back to school, but i'm encountering a problem that i can't figure out. I'm trying to create a class in my CDocument class and it does the construction but deletes the object during IMPLEMENT_DYNCREATE(). FOr the remander of the program the symbol can't be resolved which means it's no longer on the heap. What's the correct way to create a class object inside of a CDoucument object?
BTW I'm using VS .NET so it's MFC v7.0
|
| Thu Aug 15, 2002 3:05 am |
|
 |
|
Omen
Joined: Wed Sep 29, 1999 7:01 am Posts: 59 Location: North Shore City, Auckland, New Zealand
|
 MFC Problems
is your object a private member of you CDocument class? also, why are you using IMPLEMENT_DYNCREATE macros?
|
| Thu Aug 15, 2002 10:00 pm |
|
 |
|
mse61
Joined: Wed Apr 18, 2001 7:01 am Posts: 6 Location: /dev/null
|
 MFC Problems
protected, and it was IDE generated code.
|
| Fri Aug 16, 2002 12:24 am |
|
 |
|
Omen
Joined: Wed Sep 29, 1999 7:01 am Posts: 59 Location: North Shore City, Auckland, New Zealand
|
 MFC Problems
well if the ide generated the code i guess we must assume it's correct. how do you know it's deleting it during the IMPLEMENT_DYNCREATE macro?
according to the mfc version i have the IMPLEMENT_DYNCREATE is implemented as:
#define IMPLEMENT_DYNCREATE(class_name, base_class_name) \ CObject* PASCAL class_name::CreateObject() \ { return new class_name; } \ IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \ class_name::CreateObject)
and IMPLEMENT_RUNTIMECLASS is implemented as:
#define IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \ CRuntimeClass* PASCAL class_name::_GetBaseClass() \ { return RUNTIME_CLASS(base_class_name); } \ AFX_COMDAT const AFX_DATADEF CRuntimeClass class_name::class##class_name = { \ #class_name, sizeof(class class_name), wSchema, pfnNew, \ &class_name::_GetBaseClass, NULL }; \ CRuntimeClass* class_name::GetRuntimeClass() const \ { return RUNTIME_CLASS(class_name); } \
and there's no delete's going on there. just the worst the syntax gets with macros and the token-pasting operator ##
if you're watching it in the watch window and it's changing during this macro, it may be something else that is trashing the heap/stack.
[ August 16, 2002: Message edited by: Omen ]</p>
|
| Fri Aug 16, 2002 8:32 am |
|
 |
|
mse61
Joined: Wed Apr 18, 2001 7:01 am Posts: 6 Location: /dev/null
|
 MFC Problems
I traced the code and the class get trashed right after the overridden and empty constructor for the CDocument object exits. What's the error, you ask? Well it can't resolve the symbol 'this'. That's the error untill our friend IMPLMENT_DYNACREATE enters the picture. Now the error is symbol 'm_CurrDivxList' not found.
|
| Sun Aug 18, 2002 1:38 am |
|
 |
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|