• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

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
0
sinaie
Asked:
sinaie
1 Solution
 
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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now