-
April 1st, 2011, 07:03 AM
#1
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???
-
April 1st, 2011, 07:22 AM
#2
Re: using CMainFrame Object inside MFC Extension DLL
Pass the CMainFrame pointer to the DLL?
-
April 2nd, 2011, 01:23 AM
#3
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.
-
April 2nd, 2011, 03:03 AM
#4
Re: using CMainFrame Object inside MFC Extension DLL
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?
Victor Nijegorodov
-
April 2nd, 2011, 03:38 AM
#5
Re: using CMainFrame Object inside MFC Extension DLL
Originally Posted by VictorN
And what is wrong for you with SendMessage/PostMessage?
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??
-
April 2nd, 2011, 03:50 AM
#6
Re: using CMainFrame Object inside MFC Extension DLL
I'd implement send/post a registered message.
Victor Nijegorodov
-
April 2nd, 2011, 05:07 AM
#7
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|