Advertisement

Quick MFC - Doc / View question

Started by June 13, 2001 02:11 PM
1 comment, last by Prairie 23 years, 7 months ago
How should I go about accessing a variable in my doc class which resides in my view class? I need to get a hold of my d3ddevice which is in my main view class for some custom loading functions. Thanks in advance; Prairie
Theoretically your document is supposed to hold all app-wide information, and that would seem to include the item you''re trying to access (as a general rule if the doc needs to know, you should put it in the doc).

Realistically if you can''t do that for whatever reason, you can iterate through all views using GetFirstViewPosition and GetNextView, and check the view type to see which one you want to talk to, or you can store pointers to the views when you bring the app up. I strongly suggest just putting the information in the document, though.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Advertisement
Thanks for the reply felisandria (you answered a question of mine a few days ago regarding mfc, which I failed to thank you for, sorry).

What I did was put the D3D and D3DDEVICE in the document class, but still set up the 3D environment with-in the view class (taking the appropriate safeguards against re-initializing and such). And from with-in the onDraw section of the CView it call''s the the appropriate DX calls for rendering (Begin() etc..), but then calls a custom document render function that takes care of drawing all of the doc specific stuff. It worked out fairly well. Thank you for your help

Prairie

This topic is closed to new replies.

Advertisement