Displaying the file without scrolling - document class, Visual Basic Programming

Displaying the file Without Scrolling:

To display a file follow the steps as shown below:

1. Generate a SDI application.

2. Type the coding as shown in the Serialize else part. The CArchive objects are used for writing or for retrieving the file.

3. Generate a global string m_pdata in the document class. To generate the global data click on the ClassView tabpage.

Enlarge the tree control of classes.

Select the CStoreDoc class.

Right click and choose the add member variable.

Specify the type as char and the variable name as *m_pdata

The GetFile() function of the CArchive is used for selecting the file to be displayed.

The GetLength() returns the size of the file.

4. Allocate the memory to the string m_pdata by using the new operator.

5. The Read function of CArchive stores the ncount characters of the file to be displayed in the string of m_pdata.

6. The string m_pdata is displayed by using AfxMessageBox.

7. The dynamically allocated memory is improved by using the delete function.

8. Construct and execute the project.

9. Choose a file and open the menu item.

10. Choose a file.

11. The contents will be displayed in the message box.

void CStoreDoc::Serialize(CArchive& ar)

{

if (ar.IsStoring())

{

}

else

{

unsigned int ncount = ar.GetFile()->GetLength();

m_pdata= new char[ncount];

ar.Read(m_pdata,ncount);

AfxMessageBox(m_pdata);

delete [] m_pdata;

}

}

Posted Date: 10/10/2012 2:03:01 AM | Location : United States







Related Discussions:- Displaying the file without scrolling - document class, Assignment Help, Ask Question on Displaying the file without scrolling - document class, Get Answer, Expert's Help, Displaying the file without scrolling - document class Discussions

Write discussion on Displaying the file without scrolling - document class
Your posts are moderated
Related Questions
While several operations take place in an expression, each part is evaluated & resolved in a predetermined order called operator precedence. You can employ parentheses to override

write a v.net function called is vowel that returns true for vowel letters

write a XML with database with book details( book id, author ,subject, published year, vendor,price, language )

A variation on the If...Then...Else statement lets you to choose from various alternatives. By adding up Else If clauses expands the functionality of the If...Then...Else statement

Steps for Creating A MDI Form: 1. Build a new form and set IsMdiContainer property to true. 2. Build a child form class to add to the form. 3. Now Right click the proj

Methods: VBScript Dictionary Object Method D escription Add Method Adds a key, item pair. Exists Method

Describe different validation controls of VB.net?

This is a member of Microsoft's Visual Basic family of development products. Other members comprise Visual Basic (Professional and Standard Editions) & Visual Basic for Application

( Wage Calculator with Tax Calculations) Develop an application that calculates an employee’s earnings, as shown in Fig. 4.23. The user should provide the hourly wage and number of

Ask question #Minimum 10Public Class Form1 ''=============================================== ''Date: June 24, 2014 ''Author: Xochitl Nisbet ''Purpose: Convert Celsi