using CMainFrame Object inside MFC Extension DLL
hi,
My project is divided into two different project one is coredll where i am putting different resources and second is the exe project where i have CMainFrame Cview and CDoc classes.
Now i have a situation in which i need to use CMainFrame's user defined function , what would be a good way to communicate with it without using Send Message or post message. Can i get its CMainFram pointer ???
One solution i guess i should put my cmainframe inside dll which i am not interested in doing that ....any other idea???
Re: using CMainFrame Object inside MFC Extension DLL
Pass the CMainFrame pointer to the DLL?
Re: using CMainFrame Object inside MFC Extension DLL
problem is the dll doesnt know the declaration of CMainFrame and telling its header file and cpp file through directory makes more problem for me ..it seems like i am lost. :(
Re: using CMainFrame Object inside MFC Extension DLL
Quote:
Originally Posted by
Wolvorine
...
what would be a good way to communicate with it without using Send Message or post message. Can i get its CMainFram pointer ???
And what is wrong for you with SendMessage/PostMessage? :confused:
Re: using CMainFrame Object inside MFC Extension DLL
Quote:
Originally Posted by
VictorN
And what is wrong for you with SendMessage/PostMessage? :confused:
there is nothing wrong with it, i was just wondering if i can do without the send and post messages by using its own object. But i think there is no other way except send /post ...what you think??
Re: using CMainFrame Object inside MFC Extension DLL
I'd implement send/post a registered message.
Re: using CMainFrame Object inside MFC Extension DLL
I did this way:
1 - Define you function in dll (ny parameters)
typedef void (CALLBACK* MYFUNCTION)(int i,float f);
//////////////////////////////////////////////////////////////////////////
2 - in dll .h file declare
public:
void SetMyFunc(MYFUNCTION pProc);
private:
MYFUNCTION m_pMyFunc;
///////////////////////////////////////////////////////////////////////////
in dll .cpp file implement
void CMyDllClass::SetMyFunc(MYFUNCTION pProc)
{
m_pMyFunc=pProc;
}
///////////////////////////////////////////////////////////////////////////
3 - now in MainFrame
.h
public:
static void CALLBACK MyFunction(int i,float f);
private:
CMyDllClass m_DllClass;
///////////////////////////////////////////////////////////////////
.cpp
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_DllClass.SetMyFunc(MyFunction);
return 0;
}
void CMainFrame::MyFunction(int i,float f)
{
CMainFrame* pThisFrame=(CMainFrame*)::AfxGetMainWnd(); //?? or whatever you need
}
////////////////////////////////////////////////////////////////////////
4 - and last when you need to call function from dll just call
m_pMyFunc(1,15.f); //for example
and it will call function in MainFrame