Several questions worth thinking and paying attention to in VC programming

xiaoxiao2021-03-06  91

Http://91mail.51.net

1 We have some principles when using the MFC class library, it must be observed, that is, the VC prompts us to write the code there, we must write there, for example.

Void csingaldlg :: overdestroy () {// Todo: add Your message handler code here ccoatapp * PAPP = (ccoatapp *) AFXGetApp (); PAPP-> m_precordset-> close (); PAPP-> m_inquire = false;

CDIALOG :: ONDESTROY ();

This is correct, if so

Void Csingaldlg :: ONDESTROY () {// Todo: Add Your Message Handler Code Here

CDIALOG :: ONDESTROY (); ccoatapp * PAPP = (ccoatapp *) AFXGetApp (); PAPP-> m_precordset-> close (); PAPP-> m_inquire = false;}

Then there will be an abnormality in the program, which is caused by the reasons for the structure of the MFC.

2 MFCs provide some methods and functions are not very complete, and Such as

GetChunk method (ADO)

Returns all or part of the large text or binary data Field object.

grammar

Variable = Field.getChunk (size)

return value

Return the variable body.

parameter

Size long integer expressions, equal to the number of bytes or characters to be retrieved.

Description

Some or all long binary or character data are retrieved using the getchunk method of the field object. In the case where the system is limited, the GetChunk method can be used to handle the portion instead of all long integer values.

The data returned by the getChunk call will assign it to the "variable". If size is greater than the remaining data, getChunk only returns the remaining data without populating the "variable" with a blank. If the field is empty, the getChunk method returns NULL.

Each subsequent GetChunk call will retrieve data starting from the previous GetChunk call stop. However, if the data is retrieved from a field and then set or read in the current record, the ADO will consider the data from the first field. If the getchunk method is called again on the first field, the ADO will interpret the call as a new GetChunk operation and start reading from the beginning of the record. If other Recordset objects are not a copy of the first RECORDSET object, the fields that are accessed do not destroy the getChunk operation.

If the Adfldlong bit in the Attributes property of the Field object is set to True, you can use the getChunk method for this field.

If there is no current record when using a getchunk method on the field object, an error 3021 (no current record) is generated.

This method of use of the GetChunk method in a part of the reddish text, if you don't see the MSDN, you will only feel that your program has problems.

转载请注明原文地址:https://www.9cbs.com/read-122454.html

New Post(0)