Passing Parameters to MFC View Before OnCreateClient

583 Views Asked by At

I have an MFC MDI app based on Doc/View Architecture. The problem is that I want to pass some parameters to the View class from the main frame "before" OnCreateClient is called. I am not sure how I can do that as most of the stuff in the doc/ view architecture is done under the hood.

1

There are 1 best solutions below

1
user244795 On

Vague question can only be met with vague answers. Please clarify what your parameters do. Are they view-specific? Document-specific? Not visible to the user?

If your problem is that you have multiple view classes which all use a shared data structure, you could use make the shared data structure a global variable which you initialize in your CWinApp-derived class. Or you could (multiply-)derive them from (both CView and) a parent class that manages the shared data structure.

You could read your parameters from the Windows registry. You might want to do this to save the sizes of windows, their styles, etc.

I don't see what OnCreateClient has to do with any of it, though. If CView::GetDocument() returns NULL then your CView-derived class shouldn't be trying to draw anything.