|
I crreate two MFC DLL projects for 3ds max plugin.
Frist project is called maxCameraPathMFC ,which call the fDoExport function of maxCameraPathExporterMFC (second project).
int maxCameraPathMFC::DoExport(const TCHAR* name,ExpInterface* ei,Interface* i, BOOL suppressPrompts, DWORD options)
{
typedef int (CALLBACK* D_MYEXPORT)(const TCHAR*,ExpInterface*,Interface*,BOOL,DWORD);
HMODULE l_mod;
D_MYEXPORT l_export=NULL;
int l_ret=0;
l_mod=LoadLibrary("plugins_akira\\2\\maxCameraPathExporterMFC.dle");
if (l_mod!=NULL)
{
l_export=(D_MYEXPORT)GetProcAddress(l_mod,"fDoExport");
l_ret=l_export(name,ei,i,suppressPrompts,options);
FreeLibrary(l_mod);
}
return TRUE;
}
Second project is called maxCameraPathExporterMFC,which is based on KW X-port source code. The project's fDoExport function calls the IGamExporter's DoExport as below:
int __stdcall
fDoExport(const TCHAR *name,
ExpInterface *ei,
Interface *i,
BOOL suppressPrompts,
DWORD options)
{
if(!suppressPrompts)
{
{
IGameExporter* pIGameExporter=new IGameExporter();
pIGameExporter->DoExport(name,ei,i,suppressPrompts,options);
delete pIGameExporter;
}
}
return TRUE;
}
I export XFile by first project's dll, and then call the second project's fDoExport. The XFile is really exported successfully. But when I close the 3ds max, it appears an error message of Unhandle exception (http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/3ds%20max%20two%20%20plugin%20error%20Q2.JPG).
Colud somebody tell how to solve this probolem?
I put the complete source code at the web (http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/maxCameraPathQ2.rar)
|
|
|
|
|
Hello,
I am using CRecordset to access MSSQL database. I use CString to bind
the varchar datatype.
When a empty string is assigned to the CString variable and update,
the length is not correct.
The following steps can repeat the problem:
1. Assign the varchar field to "AAA"
2. Assign the CString variable to "" and then call update()
3. In Query analyzer, len() returns 3 instead of 0.
When retrieve the value and compare against '' (empty string) in ASP
code, it returns false.
Please help. Thanks.
Regards,
HM
|
|
|
|
|
Does anyone Know if there is a ON_MESSAGE macro for sending messages to Dialog box as the ON_MESSAGE looks for Cwnd *
Tnakx
|
|
|
|
|
CDialog inherits CWnd, so I don't understand your question.
Could you provide some details regarding your problem?
|
|
|
|
|
I download Popupdemo from this site after building it I got the Following compile errors
1>.\PopupDemoDlg.cpp(88) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CPopupDemoDlg::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>.\PopupDemoDlg.cpp(89) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CPopupDemoDlg::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
The cause of this seems to be
The Message map macro
BEGIN_MESSAGE_MAP(CPopupDemoDlg, CDialog)
//{{AFX_MSG_MAP(CPopupDemoDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_MESSAGE(ID_MENU_SELECTALL, OnSelectAll) <---
ON_MESSAGE(ID_MENU_COPY, OnCopy) <---
Point to functions OnSelectAll, and Oncopy Which are members CpopupDemoDlg which is a CDialog type
Which in a way makes sense since you do a SendMessage typically to a Cwnd not a Cdialog
was just wondering if there was a way around this error
thankx
|
|
|
|
|
can you give a link to the article you downloaded this from?
|
|
|
|
|
//www.codeproject.com/KB/edit/popupdemo.aspx
The Code Doesn't compile I basically was looking for Code on how to Create a CRichEditCtrl object
If I have it ( the Rich Edit Control ) defined in my resource member
thankx
|
|
|
|
|
Change ON_MESSAGE to ON_COMMAND
That fixes the compile errors.
EDIT:
Pay no attention to my answer, Stuart's answer below is much better, and most likely works!
|
|
|
|
|
Richard Andrew x64 wrote: That fixes the compile errors.
But stops the application working - the context menu IDs are actually sent to the application as window messages, using PostMessage, rather than as commands.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
yeap tried that the oncopy onselect dont seem to be menu commands
|
|
|
|
|
No, they're not - they're sent as window messages. Change the OnCopy and OnSelectAll signatures as per my other post and you'll be good. Trust me - I built & tested the demo with those changes
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
A CDialog derives from CWnd - that part of the error message is a red herring.
The trouble is that the code uses the wrong signatures for the OnSelectAll and OnCopy handlers. This didn't matter on VC6, as the C++ compiler was less discriminating than it is now, but on VC++2003 and later, the compiler will (correctly) tell you that that you're trying to cast a method pointer to an incompatible method pointer (because that's what OnCopy/OnSelectAll are in the ON_MESSAGE macro).
I can understand why the original author had those signatures (menu commands are usually handled with ON_COMMAND, but the way he's handled the context menu, they have to be handled with ON_MESSAGE here).
Anyway, change OnCopy and OnSelectAll declaration and definition so they a) return an LRESULT, and b) take a WPARAM and an LPARAM parameter and you'll be sorted. As an example, OnSelectAll should look like this in your class definition:
LRESULT OnCopy(WPARAM, LPARAM);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I added return of TRUE;
e.g. return TRUE; to both methods
thankx again
|
|
|
|
|
I'm working on a straight C program in Visual Studio 6.0.
I added a few calls to malloc() today, and malloc fails every time with a NULL return value. GetLastError() returns 998 - Invalid access to memory location.
The process is using only about 5 MB of RAM when this occurs, and I've restarted XP several times without curing the problem.
No other process on the system shows any signs of running out of memory.
When I replace calls to malloc with calls to HeapAlloc(), the program runs fine.
Can anyone think of a reason why malloc might be failing?
|
|
|
|
|
Are you absolutely sure it's malloc that's causing that error code (use SetLastError to reset the thread's error code immediately before the malloc call)?
If so, all I can suggest is single-stepping through malloc (you have got the CRT source installed haven't you?) in the debugger and seeing where it fails. It's not so tricky
I'm afraid I can't help further, as I haven't had VC6 installed anywhere for ages (and don't even know where I could lay my hands on the install media).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks, Stuart.
I will try stepping through again. But I find it more or less fruitless because I haven't a clue how the CRT operates, and I find it very difficult to read that code with all the underscores!
|
|
|
|
|
Can you build a new program that only uses malloc and see what happens.
If you view the assembly does malloc actually get called.
Can you post the code.
a programmer traped in a thugs body
|
|
|
|
|
Thanks for your interest.
I will look at the assembly as you suggest.
I can't post the code until I get to work tomorrow, but I'll do so if I can't solve it on my own.
|
|
|
|
|
me sathish
u r allocating more mem tht the system can't hold using malloc.
so only u can use heap functions to allocate more.
ya
|
|
|
|
|
Hello,
I am having a problem with setting up a necessary circular dependency.
I have a class (MessageHandler) which inherits from a "interface" as much as you're allowed to do that in c++. It also contains a queue (TaskQueue). and here is the circular bit: the TaskQueue needs a reference to the MessageHandler. The other catch is that the Tasks in TaskQueue need to know about the MessageHandler.
So the code goes like this (or at least the screwy parts):
(in MessageHandler.h)
#ifndef MESSAGE_HANDLER_H
#define MESSAGE_HANDLER_H
#include "TaskQueue.h"
class MessageHandler : public somenamespace:someclass {
private:
TaskQueue tq;
someobj& ref;
...
public:
MessageHandler (someobj& r) : ref (r) {
tq.setMessageHandler (&this);
..
}
};
#endif
(MessageHandler.C)
#include "MessageHandler.C"
..some functions making use of tq..
(in TaskQueue.h)
#ifndef TASK_QUEUE_H
#define TASK_QUEUE_H
#include "Tasks.h"
class MessageHandler;
class TaskQueue : public someotherclass {
private:
MessageHandler* msg_handler;
..other queue-things...
public:
TaskQueue () {...}
inline void setMessageHandler (const MessageHandler* mh) { msg_handler = mh; }
void doSomething () {
msg_handler->doSomething ();
}
};
#endif
(in Tasks.h)
#ifndef TASK_H
#define TASK_H
class MessageHandler;
class Task {
private:
MessageHandler* msg_h;
public:
Task (const MessageHandler* mh) {msg_h = mh;}
}
(int Tasks.C)
#include "Tasks.h"
void Task::someFunction () {
msg_h->someFunction ();
}
#endif
I am not sure if the forward declaration is right; do I need to include the ": public..." inheritance stuff?
Main is somewhere else, and it just does has:
#include "MessageHandler.h"
...
MessageHandler msg_handler;
...
that part is pretty standard.
The first couple of errors I get from the compiler (gcc) is:
./include/MessageHandler.h:18: error: declaration of âstruct TaskQueue::MessageHandlerâ
./include/Tasks.h:21: error: changes meaning of âMessageHandlerâ from âstruct MessageHandlerâ
./include/MessageHandler.h:21: error: field âtask_qâ has incomplete type
./include/MessageHandler.h:24: error: expected â,â or â...â before â:â token
....all hell breaks loose
Any help is appreciated!
|
|
|
|
|
It wouldn't be that you have:
(MessageHandler.C)
#include "MessageHandler.C"
when you meant #include MessageHandler.h ?
|
|
|
|
|
In the code I do have the latter not the prior.
just a typo from the code -> post transition. Thanks!
|
|
|
|
|
thelonesquirrely wrote: (in TaskQueue.h)
#ifndef TASK_QUEUE_H
#define TASK_QUEUE_H
#include "Tasks.h"
class MessageHandler; //forward declaration
It seems you don't understand the fundamental concept of a forward declaration. It provides the mechanism for the storage of a typed pointer without the inclusion of the header file.
In your post Tasks.h defines MessageHandler so the the inclusion of the header file negates the need to use a forward declaration.
class A{
void what(){ printf("hello"); }
};
class A;
class B{
A* myAPtr;
void myFunc();
};
#include "B.h"
#include "A.h"
void B::myFunc(){ myAPtr->what(); }
|
|
|
|
|
I compiled a large subset of the code you supplied in gcc 4.0.1 and found the following issues:
- In the Task constructor, you attempt to convert a const pointer to a non-const pointer - that's a no-no.
- In TaskQueue.h, you effectively have two forward declarations of MessageHandler (one in TaskQueue.h, one from #including Tasks.h) - that's not allowed, so remove the one in TaskQueue.h - you always #include Tasks.h, so you know you'll have the forward declaration from there.
- Again, in TaskQueue::setMessageHandler, you are converting a const pointer to a non-const pointer
- You forward declared MessageHandler in TaskQueue.h - therefore, you do not know what methods MessageHandler has, so you can't call them in the header (as you've done in TaskQueue::doSomething). You can only call them after you've got a complete declaration of MessageHandler (i.e. in a TaskQueue.C, after you've #included MessageHandler.h)
- You use '&this' in the MessageHandler constructor - this will give a MessageHandler**, as 'this' is a MessageHandler*
- Your Task class isn't terminated with a semi-colon. This *can* cause torrents of incomprehensible error messages...
Fix them and I suspect your compilation problems may go away.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You guys are awesome! thanks! Now I finally have a better understanding of the #include structure and forward declarations! Thanks!!!
|
|
|
|