getting var from document in vc++

Hi,

I am creating my data in a document, from the view object I'm using getDocument() to get data from the document.
How can I get the data from OnInitDialog()?
I need the data so I can change the initial state of the dialog.
Thanks
Eyal
sinaieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

danelroismanCommented:
Eyal!

GetDocument() allow you get pointer to document to get data from it.
But OnInitDialog() is a message function of CDialog, how you can get data from it ?!

But you can send user-defined message
from the body of OnInitDialg(),so when you dialog will be active you can get this message with parameters you send.

Good Luck!

Daniel



 
0
sinaieAuthor Commented:
Thanks,
But I need to get data from the document while activating OnInitDialog().
This data will define exactly how the dialog will apear.
The dialog is a modal one and I activate it from the mainApp.

Thanks again
Eyal
0
mikeblasCommented:
sinaie> But I need to get data from the document while activating OnInitDialog().
sinaie> This data will define exactly how the dialog will apear.
sinaie> The dialog is a modal one and I activate it from the mainApp.

Then, you have a problem.

If your application is creating the dialog, what guarantees that there _is_ a document? Shouldn't this creation code be in the view, so that you inherently know what document the user thinks they're referring to when the dialog comes up?

If you absolutely must, you can do this:

CDocument* GetMyDocument()
{
   // get the main window
   CWnd* pWnd = AfxGetMainWnd();
   CFrameWnd* pFrameWindow = DYNAMIC_DOWNCAST(CFrameWnd, pWnd);
   if (pFrameWindow == NULL)
   {
      // the main window isn't a frame window!
      return NULL;
   }
   
   return pFrameWindow->GetActiveDocument();
}

but that code has issues--specifically, that you'll need to keep an eye on the return value to make sure it gives you back a pointer to the document type you expect.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.