CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2011
    Posts
    6

    Question Passing Parameters to a View from CMDIFrameWnd

    Hi,

    When I create a document in an MDI app from CMDIFrameWnd, the associated view is automatically created. Now, I want to pass the View (a subclass of CMDIChildWnd) some parameters from CMDIFrameWnd (which are independent of the document).

    The view will use these parameters for drawing its client area, and hence they have to reach the view before ::OnCreateClient is called.

    Can anyone help here, and give me some hints/ articles to read to implement this behaviour?

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Passing Parameters to a View from CMDIFrameWnd

    AfxGetMainWnd() will give you a pointer to your app's main window.

  3. #3
    Join Date
    Jun 2011
    Posts
    6

    Re: Passing Parameters to a View from CMDIFrameWnd

    which means that there is no way to pass the parameter?

    Would this approach of accessing back the main window thread-safe? Is there any way a second view is created by the time I access the main app from MDIChildWnd (and hence the parameters change)?

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Passing Parameters to a View from CMDIFrameWnd

    Quote Originally Posted by piedpiper View Post
    which means that there is no way to pass the parameter?

    Would this approach of accessing back the main window thread-safe? Is there any way a second view is created by the time I access the main app from MDIChildWnd (and hence the parameters change)?
    There seem to be some design issues the way you described your question.

    You don't create documents from CMDIChildWnd and views aren't subclassed from CMDIChildWnd, so I'm not really sure how to answer you, but no, I don't believe you can pass parameters directly from the main window to the CMDIChildFrame of the view during creation without overriding parts of the framework.

    The document object is created before the views though, so perhaps you could put some parameters in there of use OnInitialUpdate in the view class to get info from the doc.
    Last edited by GCDEF; June 7th, 2011 at 09:21 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured