Discussion:
Get a pointer to CMainFrame in CView class
(too old to reply)
Goodmannewz
2006-01-31 07:50:05 UTC
Permalink
Hi,
My question is how to get a pointer to CMainFrame in CView class?
For example, I create a SDI project named "TestMFC". In TestMFCView class,
how to get a pointer to CMainFrame?

Thanks.
David Lowndes
2006-01-31 10:08:06 UTC
Permalink
Post by Goodmannewz
My question is how to get a pointer to CMainFrame in CView class?
Use AfxGetMainWnd():

CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();

Dave
hereafter
2006-02-07 06:21:46 UTC
Permalink
GetParentFrame() from CView class
Post by Goodmannewz
Hi,
My question is how to get a pointer to CMainFrame in CView class?
For example, I create a SDI project named "TestMFC". In TestMFCView class,
how to get a pointer to CMainFrame?
Thanks.
Ajay Kalra
2006-02-10 17:56:40 UTC
Permalink
Keep in mind though this is not as clean as AfxGetMainWnd as this will fail
in MDI and AfxGetMainWnd will not. I will go with AfxGetMainWnd.

--
Ajay Kalra [MVP - VC++]
Post by hereafter
GetParentFrame() from CView class
Post by Goodmannewz
Hi,
My question is how to get a pointer to CMainFrame in CView class?
For example, I create a SDI project named "TestMFC". In TestMFCView class,
how to get a pointer to CMainFrame?
Thanks.
Loading...