Calling a Function in CMainFrame
-
Hi, I have a MFC app with a main form (CMainFrame) and a dialog. How can I call a member function of CMainFrame from another dialog?
-
Hi, I have a MFC app with a main form (CMainFrame) and a dialog. How can I call a member function of CMainFrame from another dialog?
One way is to pass the CMainFrame into your dialog. Another is to use the m_pMainWnd member from your application object like this: CMainFrame* mainFrame = dynamic_cast(AfxGetApp()->m_pMainWnd); mainFrame->doThisMemberMethod();
-
One way is to pass the CMainFrame into your dialog. Another is to use the m_pMainWnd member from your application object like this: CMainFrame* mainFrame = dynamic_cast(AfxGetApp()->m_pMainWnd); mainFrame->doThisMemberMethod();
Hey, I tried that. But while compiling I am getting error: error C2059: syntax error : ')' I can't figure out why. Can u please help me?
-
One way is to pass the CMainFrame into your dialog. Another is to use the m_pMainWnd member from your application object like this: CMainFrame* mainFrame = dynamic_cast(AfxGetApp()->m_pMainWnd); mainFrame->doThisMemberMethod();
Oh! I looked at MSDN and found the correct way to use it. The code should be as follows:
CMainFrame* mainFrame = dynamic_cast(AfxGetApp()->m_pMainWnd); mainFrame->doThisMemberMethod();
Thanks. -- modified at 6:26 Sunday 17th June, 2007 -
Oh! I looked at MSDN and found the correct way to use it. The code should be as follows:
CMainFrame* mainFrame = dynamic_cast(AfxGetApp()->m_pMainWnd); mainFrame->doThisMemberMethod();
Thanks. -- modified at 6:26 Sunday 17th June, 2007Ooops. I copied the code from one of my own projects and had to rename things from my class name to CMainFrame. I accidentally erased . Very sorry about that. Glad you still figured it out. I ran into my own pet peeve of someone giving a code example which doesn't work.
-
Ooops. I copied the code from one of my own projects and had to rename things from my class name to CMainFrame. I accidentally erased . Very sorry about that. Glad you still figured it out. I ran into my own pet peeve of someone giving a code example which doesn't work.
Hmmm, strange. Apparently I did not erase it. It seems the forum is completely deleting my code. I just typed it again in my previous message and it does not show up in the post. Somehow it worked when you typed it in your post. I wonder why.
-
Hmmm, strange. Apparently I did not erase it. It seems the forum is completely deleting my code. I just typed it again in my previous message and it does not show up in the post. Somehow it worked when you typed it in your post. I wonder why.
StevenS_Dev wrote:
It seems the forum is completely deleting my code.
No, it's there, albeit not shown. You are just failing to use the angle brackets above the smileys.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne