Skip to main content
gamedev.net
🔒 Locked

CView/CDocument

Started by doctorsixstring 4 replies 300+ views
Original Post
doctorsixstring
doctorsixstring
In my SDI MFC app, I have a few classes that need to interact with the CView object. I am fairly experience with C++, but since this is MFC, I can''t quite figure out how to exchange data between the CView/CDocument objects and my new objects. The function DoDataExchange() looks promising, but I''m not really sure. Does any one have any ideas? Thanks in advance, -Mike
doctorsixstring
doctorsixstring
Perhaps I should rephrase my question:

How can I gain access to the CView object of my MFC app? It looks like the following code creates the View, Document, and MainFrame objects.


  
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyProgramDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window

RUNTIME_CLASS(CMyProgramView));
AddDocTemplate(pDocTemplate);


I want to be able to store a pointer to the CMyProgramView object, or find some other way to access that object from other MFC objects. I''m sure there is some easy way to do this, but I can''t seem to find it.

Any thoughts at all would be greatly appreciated.

-Mike
TDragon
TDragon
Well, I''d really like to help you, but I''d be going in over my head. I have found that often times MFC is a hassle, a mess, and a big pain when trying to do something simple, and that''s why I stick to straight Win32.

Twilight Dragon
Win32 API Programmer
www.freewebz.com/j-world
niyaw
niyaw
CDocTemplate::GetFirstDocPosition
CDocTemplate::GetNextDoc
CDocument::GetFirstViewPosition
CDocument::GetNextView
niyaw
niyaw
quote:
Original post by TDragon
Well, I''d really like to help you, but I''d be going in over my head. I have found that often times MFC is a hassle, a mess, and a big pain when trying to do something simple, and that''s why I stick to straight Win32.


you do know what msdn is, right? it took me all of thirty seconds to open it and look at class members under doctemplate and document. maybe you should learn to use your browser productively.

or maybe you keep writing wndprocs that only have one handler, WM_DESTROY?

now getting through these timeout errors takes much longer.

500 errors x17
doctorsixstring
doctorsixstring
Thanks for the replies guys. After much additional MSDN perusing, and reading your posts, I came up with this jolly bit of code:

//////////////
//called from function in sub-sub dialog window object
CWnd* pwndMain = GetParent()->GetParent()->GetParent();
m_pMainView = ((CFrameWnd*)pwndMain)->GetActiveView();
//////////////

Looks great, doesn''t it? Well anyways, it works, and I now have a pointer to my main view object from within my new classes.

-Mike

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.