Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Adding File Contents to AddRecordEx
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding File Contents to AddRecordEx

 Post Reply Post Reply
Author
Message
EASX View Drop Down
Newbie
Newbie
Avatar

Joined: 30 September 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote EASX Quote  Post ReplyReply Direct Link To This Post Topic: Adding File Contents to AddRecordEx
    Posted: 27 October 2009 at 4:39am
Hey I've been playing with the sample "Report Sample for AddRecordEx" and I was wondering if it'd be possible to display file contents in different nodes. I really like how each node can be expanded and collapsed, so I think it would be convenient if a different .txt file could be displayed in each node, since they could be minimized and what not. But when I try the following code, the application crashes.

   
CString MyString;
    CStdioFile Input ( "TestText.txt", CFile::modeRead );
    for(int i = 0; i < 6; i++ )
    {
        Input.ReadString ( MyString );

        CMessageRecord* pMsg = new CMessageRecord ( MyString.GetString() );

        if(pMsg)
            pReportCtrl->SendMessage(WM_ADD_RECORD_EX, (WPARAM)pMsg, MAKELPARAM(i, 6));

        if (pReportCtrl->GetParent())
        {
            CString strCaption(_T("Report Sample for AddRecordEx"));

            if (i + 1 < 6)
                strCaption.Format(_T("Report Sample for AddRecordEx [%d of %d]"), i+1, 6);

            pReportCtrl->GetParent()->SetWindowText(strCaption);
        }
    }


I'm sure I'm missing something, but I'm not sure what. If someone could help me out that'd be great

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 October 2009 at 4:29pm
Did you change CMessageRecord constructor? We have in sample - CMessageRecord(CString strItem1, CString strItem2, CString strItem3, CString strItem4); - smth like this - CMessageRecord(CString strItem1, CString strItem2 = _T(""), CString strItem3 = _T(""), CString strItem4 = _T("")); ?
 
In this case use CMessageRecord* pMsg = new CMessageRecord(MyString);
instead of your way - CMessageRecord* pMsg = new CMessageRecord ( MyString.GetString() );
which generate memory leak.... Also be sure you have proper path and file exist - like this:

CStdioFile Input( "F:\\CodejockSVN\\bin\\TestText.txt", CFile::modeRead );

Now all working well - but you will have each line of your text file as content of 1st item - row by row - no nodes...
 
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.