Print Page | Close Window

Adding File Contents to AddRecordEx

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=15464
Printed Date: 29 September 2024 at 3:20pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Adding File Contents to AddRecordEx
Posted By: EASX
Subject: Adding File Contents to AddRecordEx
Date 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




Replies:
Posted By: mdoubson
Date 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...
 


-------------
Mark Doubson, Ph.D.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net