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

    Writing in view from another dialog

    I want to write into view window from a dialog (to present data for printer!)
    I have simply created CDC object and used TextOut but it is not working.
    How can I write into view window from another new dialog.
    Please help


  2. #2
    Join Date
    May 1999
    Posts
    92

    Re: Writing in view from another dialog

    What I would try is use a sink approach to accomplish this. What if you had a class that was able to access the Main Frame or childframe depending on which way you go about it. You would have variables in that class that you would set from the dialog box class and you would have functions in the dialog box class that you can call that would take the information in the variables in the class and write that to the screen of the view.


  3. #3
    Join Date
    May 1999
    Posts
    92

    Re: Writing in view from another dialog

    I wrote a sample of what I was talking about in VC4.1. If you want it then send me an email and I will send it to you.


  4. #4
    Guest

    Re: Writing in view from another dialog

    add th following to your dialog header:

    #include "Your View.h"
    class ..
    {
    public:
    friend class CYourView;
    CYourView *GetView();
    ..
    };
    #ifndef _DEBUG //
    inline (CYourView* CYourDialog::GetView()
    { return (CYourView*)pView; }
    #endif

    add to your dialog-implementationfile(*.cpp):
    #ifdef _DEBUG
    CYourView *CBautagebuchDoc::GetView()
    {
    CMDIFrameWnd* pWnd = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
    CMDIChildWnd* pChild = (CMDIChildWnd*)pWnd->GetActiveFrame();

    if(!pChild)
    return NULL;

    CView *pView = pChild->GetActiveView();
    if(!pView)
    return NULL;

    POSITION pos = GetFirstViewPosition();
    while (pos != NULL && !pView->IsKindOf(RUNTIME_CLASS(CYourView)))
    {
    pView = GetNextView(pos);
    }

    return (CYour*)pView;
    }
    #endif


    ______________________

    now you can do the following in your Dialog Class:

    CYourView *pView = getView();
    pView->all_your_public_elements_and_functions

    by the way: use SetWindowText instead of TextOut!!!
    Rene´



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