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
Assume that s is a string variable that is supposed to contain a value to be converted to integer. Write a fragment of code that converts the value to integer variable and displ

Restricting The Vocabulary: The properly formed vocabulary is like an inverted pyramid. All easy to learn communication system follow this pattern. The canonical vocabulary in

Dialog Based Application: The application which app wizard generates is based on the dialog template resource.

Creating an application that will calculate the cost of a car rental based on the number of days that the car is rented. the cost of the car rental includes the cost of the car its

Variable Length Strings: The Strings can be declared using As or $ as shown in the code below; the msg and msg1 are the two strings and they are assigned the values using '='.

Question 1 Create a VB application to make the text bold, italic, underlined and also color the text (using checkbox, option button, textbox controls) Question 2 Create a

Create a Visual Basic that allows a user to play a variation of Hangman. User Inputs The user types a letter into the textbox.   Functional Items 1. Read a

Variables must always be described with the smallest scope possible. VBScript variables can have the given scope. Scope Where Variable is Declared

Write Visual Basic programs for the following: 1.     Write a program that uses a "For Loop" to generate a list of temperature conversions in one degree increments from a given

Problem 1. Describe the importance and usage of .net framework in visual Studio 2. Write a program to sort and display an array of integers in ascending order using the conc