Passing data from App to Doc

This is a discussion on Passing data from App to Doc within the Windows Programming forums, part of the Platform Specific Boards category; I read file and parse it in App class. After that I need to pass parsing data into bunch of ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    2

    Question Passing data from App to Doc

    I read file and parse it in App class. After that I need to pass parsing data into bunch of Doc/View's. I found one solution: create temporary (parsed) file in App and read it in each Doc.
    But I feel that possible better solution whithout creating temp. file.
    Any idea how to do it?

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    parse file in app

    Why would you want a file to be passed to a bunch of docs?
    Of course you know the relationship between the Doc and the views I assume. One doc can be related to many views but the views can only be related to exactly one doc. If you truly need all the different docs to access to this parsed file, I am afraid you have the best solution.
    zMan

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    2

    Re:

    The problem that I don't know initially how many pairs doc/view I need.
    I have following code. I thought I could pass data through CCommandLineInfo (ProcessShellCommand(cmdInfo)) and catch it in constructor of each Doc.

    void CParseApp::OnFileOpen()
    {
    CFileDialog fileDlg(TRUE,
    ".txt",
    NULL,
    OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
    "All Files (*.*)|*.*||",
    m_pMainWnd);
    if(IDOK == fileDlg.DoModal())
    {
    CFileBreaker fb((LPCTSTR)fileDlg.GetPathName());
    vector<DString> vLines = fb.BreakOn("\n");
    int childs = vLines.size();
    CParser parser(vLines);
    vector<DString> vNames = parser.GetNames();
    vector<vector<int> > vvScores = parser.ParseScores();

    static_cast<CMainFrame*>(AfxGetMainWnd())->SetChildNumber(childs);

    ofstream file("Results.bul");
    vector<vector<int> >::iterator vvIter = Data.begin();
    file << static_cast<int>(m_bBorder) << '\n';
    for(int i = 0; vvIter != vvData.end(); vvIter++, i++)
    {
    file << vNames[i] << ' ';
    for(int k = 0; k < (*vvIter).size(); k++)
    file << (*vvIter)[k] << ' ';
    file << '\n';
    }
    file.close();
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    for(int j = 0; j < childs; j++)
    {
    if (!ProcessShellCommand(cmdInfo))
    {
    ::AfxMessageBox("Fail to create child frame.\nApplication is closing.");
    AfxGetMainWnd()->SendMessage(WM_DESTROY);
    }
    }
    m_pMainWnd->SetWindowText(fileDlg.GetFileTitle());
    :eleteFile("Results.bul");
    }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing data between functions
    By nesagsar in forum C++ Programming
    Replies: 11
    Last Post: 12-08-2006, 11:48 AM
  2. functions and passing data
    By redmondtab in forum C Programming
    Replies: 41
    Last Post: 09-21-2006, 12:04 PM
  3. data passing
    By jerrykelleyjr in forum C++ Programming
    Replies: 5
    Last Post: 12-27-2004, 02:45 PM
  4. passing constructor data to other constructors
    By eth0 in forum C++ Programming
    Replies: 9
    Last Post: 05-21-2004, 03:20 AM
  5. C Programming Question
    By TK in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-04-2002, 07:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21