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
Device Contexts: The Device Context (DC) is represented by the data type Handle to Device Context (HDC). The HDC is a handle to somewhat you can draw on; it can be the whole s

Explain difference, Generic Variable: Create Object Ex:-Ole-Automation . No need refer the object library. What is Specific Variable: Binding Procedure Early & Late Binding ( Can

What are the differences between Property Get, Set and Let? Set - Value assigned to ActiveX Object from the form. Let - Value retried to ActiveX Object from the form. Get- Assigns

Default Values for GDI Objects: The default color for the brush is white, pen is black, and default bitmap is null and the default font is system.

Just like normal objects Dictionary object also has definite properties. These properties can be set to any valid value & can be retrieved as and while required. Pr

You declare variables explicitly in script via the Dim statement, the Public statement, & the Private statement. For illustration: Dim DegreesFahrenheit You declare multiple

Create a VB calculator application that appears as in the screen shots below. The user enters numbers in the textboxes labelled Number 1 and Number 2. When a calculati

Fixed length strings: The Fixed length strings are declared by identifying the size of the string. For illustration to give a length of 20 for the string place, the declarati

Indexing: In libraries, the card catalog is the index. The three indices are used in the library. The Author, Subject and title are the 3 indices. Each index is relative. The

everything about events