Visual C ++ MFC commonly used macros meaning (reprint)

   AND_CATCHAND_CATCH

  AND_CATCH (exception_class, Exception _object_point_name)

  Description:

   Defines a code block used to obtain additional types of exceptions TRY abolished in the current block. Used to obtain a macro CATCH exception type, then obtain subsequent macro AND_CATCH exception handling code can access the exception object (if appropriate) has been more about the particular cause of the abnormality. AND_CATCH call THROW_LAST macro block so as to move to the next process abnormal external frame. AND_CATCH may be labeled or AND_CATCH CATCH end block.

  NOTE:

  AND_CATCH block is defined as a C ++ scope (described in braces).
If the user of this scope defined variables, remember that they can only be accessed in this scope. He also used exception_object_pointer_name variables.

  The ASSERT

  the ASSERT (the BooleanExpression)

  Description:

   Calcd variable. If the structure is 0, then the macro will print a diagnostic message and fail to hearing. If the condition is non-zero, then do nothing. In the form of diagnostic messages are: assertion failed in file in line where name is the name of the metafile, num is the source file fail interrupt number. In the Release version, ASSERT not counting the value of the expression is also not interrupt program. If you must calculate the value of this expression and regardless of the environment they use VERIFY instead of ASSERT.

  Notes:

  ASSERT in Debug version with only

  ASSERT_VAILD

  ASSERT_VAILD (pObject)

  Description:

   for detecting an internal state of the object on the effectiveness. ASSERT_VALID AssertValid call a member function of this object (to pass them as their variable). ASSERT_VALID do nothing in the Release version. In the DEBUG version, he checked the pointer to NULL is different way to check and call the object's own AssertValid member functions. If any of these tests have a failure, then he will display a warning message to the ASSERT same way.

  Note:

  This function is only available in DEBUG version.

  BEGIN_MESSAGE_MAP

  BEGIN_MESSAGE_MAP (The class, BaseClass)

  Description:

  using the user defined start BEGIN_MESSAGE_MAP message map. In the definition of the class user function tool (.cpp) file, a start message to the macro BEGIN_MESSAGE_MAP map, then increase the macro entry for each message processing function, followed by the macro END_MESSAGE_MAP map complete message.

  The CATCH

  the CATCH (exception_class, exception_object_pointer_name)

  Description:

   Using this definition of a code block with this code is used to obtain the current block are a TRY exception type. Exception handling code can access the exception object, how appropriate, will get more information about the specific cause of the anomaly. THROW_LAST macro to call the process a bit abnormal external framework, if the exception-class is the class CExceptioon, you will get all types of exceptions. Users can use the CObject :: IsKindOf member function to determine the particular exception is excluded. The best way is to use the acquired abnormal AND_CATCH sequential statements, each with a different exception types. This exception pointer type defined by the macro, the user need not defined.

  NOTE:

  This CATCH block is defined as a range of C ++ (described in braces). In this range, such as user-defined variables, then they can only be accessed within the range of eating. He also used the name of the exception object pointer.

  DEBUG_NEW

  #define new new DEBUG_NEW

  Description:

   help find memory errors. User DEBUG_NEW in the program, users generally use the new operator is allocated from the heap. In Debug mode (DEBUG but defines a symbol), each object record DEBUG_NEW file name and line number allocated to it. Then, when the user uses CMemoryState :: DumpAllObjectSince member functions, each assigned to the object DEBUG_NEW allocation of places showing the file name and line number. In order to use DEBUG_NEW, should be inserted in the user's resource file the following instructions: #define new DEBUG_NEW Once the user inserts this command preprocessor DEBUG_NEW inserted using new place, and MFC for the rest. But when users compile their own version of a release program, DEBUG_NEW it simple new operation, but does not produce the file name and line number information.

  DECLARE_DYNAMIC

  DECLARE_DYNAMIC (class_name)

  Description:

   But when a CObject-derived class, increase access this macro on a run-time function object class. The header file DECLARE_DYNAMIC macro join the class, and then in all the parts of speech need to access the object .CPP file contains this module. If, as the use of DELCARE_DYNAMIC and IMPLEMENT_DYNAMIC macro described, then the user can use the macro and the CObject :: IsKindOf RUNTIME_CLASS function to determine the object type at run time. If DECLARE_DYNAMIC included in the class definition, then IMPLEMETN_DYNAMIC must be included in the class tool.

  The DECLARE_DYNCREATE

  the DECLARE_DYNCREATE (class_name)

  Description:

   Use DECLARE_DYNCRETE macro CObject derived class in order to allow the object automatically created at run time. Use this feature to automatically create a host of new objects, for example, but it is in the process of serial read an object from disk, file and view the window and the frame should support the establishment of dynamic, because the framework needs to automatically create it. Wang added the .H file DECLARE_DYNCREATE class, then include this model all need access to such objects .CPP file. If DECLARE_DYNCREATE included in the class definition, then IMPLEMENT_DYNCREATE must be included in the class tool.

  DECLARE_MESSAGE_MAP

  DECLARE_MESSAGE_MAP ()

  Description:

   Each user program CCmdTarget derived class must provide the message map to process the message. DECLARE_MESSAGE_MAP using the class definition at the end of the macro. Next, the file .CPP class member function is defined using macro BEGIN_MESSAGE_MAP, the following list of entries for each user macro message processing functions and macros END_MESSAGE_MAP.

  Note:

  If you define any member after DECLARE_MESSAGE_MAP, you must specify a new access type for them (public, private, protected).

  The DECLARE_SERIAL

  the DECLARE_SERIAL (class_name)

  Description:

   the DECLARE_SERIAL header to generate the necessary C ++ code can be a serialized CObject derived class. Serialize the contents of an object is read and written to a file from a file. DECLARE_SERIAL use macros in .H file, then include this file in all .CPP files need access to such objects. If DECLARE_SERIAL included in the class definition, then IMPLEMENT_SERIAL must be included in the class tool. DECLARE_SERIAL macro contains all DECLARE_DYNAMIC, IMPLEMENT_DYCREATE function.

  END_CATCH

  END_CATCH

  Description:

  identifying the end of the last or AND_CATCH CATCH block.

  END_MESSAGE_MAP

  END_MESSAGE_MAP

  Description:

  Use END_MESSAGE_MAP macro defines the end user's message mapping

  the IMPLEMENT_DYNAMIC

  the IMPLEMENT_DYNAMIC (class_name, base_class_name)

  Description:

  to generate the necessary C ++ code to dynamically access class CObject derived class name and location in the structure by the serial operation. Use IMPLEMENT_DYNAMIC macro .CPP file, followed by a result of linking object code

  IMPLEMENT_DYNCREATE

  IMPLEMENT_DYNCREATE (class_name, base_class_name)

  Description:

   By DECLARE_DYNCREATE macro IMPLEMENT_DYNCREATE use macros to allow CObject derived class object is automatically created at runtime. Host use this feature to automatically create an object, for example, but it is read from the disk in the serialization process of going to a subject, he joined IMPLEMENT_DYNCREATE macro tool in class. If the user DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macro, then followed to determine the object class at run time using macros and CObject :: IsKindOf RUNTIME_CLASS member function. If declare_dyncreate included in the definition, then IMPLEMENT_DYNCREATE must be included in the class tool.

  The IMPLEMENT_SERIAL

  the IMPLEMENT_SERIAL (class_name, base_class_name, wSchema)

  Description:

  to establish the necessary C ++ code in the serial structure of dynamic access CObject derived class by the class name and location of the runtime. IMPLEMENT_SERIAL use macros in the .CPP file, and then link the resulting object once the code.

  ON_COMMAND

  ON_COMMAND (ID, memberFxn)

  Description:

   This message is mapped by a macro into ClassWizard or manually. It indicates that function from a command user interface (such as a menu item or toolbar button) processing a command message. When a command object by specifying the ID of a Windows WM_COMMAND message is received, ON_COMMAND will call the member function memberFxn processing this message. In the user's message map, for each menu command or accelerator (must be mapped to a message processing function) should ON_COMMAND does have a macro statement.

  ON_CONTROL

  ON_CONTROL (wNotifyCode, id, memberFxn)

  Description:

  indicates which functions to process a control message indicating regular. It identifies those control message transmitted from a mother to her husband control message window.

  The ON_MESSAGE

  the ON_MESSAGE (Message, memberFxn)

  Description:

   indicates which function will handle a user-defined message. User-defined message generally defined WM_USER 0x7FF to the range. User-defined messages are any messages that are not standard Windows WM_MESSAGE message. Mapping the user's message, each message must be mapped to a processing function. There should be a user-defined message ON_MESSAGE macro statement.

  ON_REGISTERED_MESSAGE

  ON_REGISTERED_MESSAGE (nmessageVarible, memberFxn)

  Description:

  the Windows RegisterWindowsMesage the window function is used to define a new message, the message is guaranteed to be unique throughout the system. This macro indicates which function processes the message has been registered. NMessageViable variable should be defined in NEAR modifier.

  The ON_UPDATE_COMMAND_UI

  the ON_UPDATE_COMMAND_UI (ID, memberFxn)

  Description:

  This macro is typically inserted through a message map ClassWizard, which function to indicate to a user interface to change a process command messages. Mapping the user's message, the user interface changes each command (specific information is mapped to a message handler) should have a ON_UPDATE_COMMAND_UI macro statement.

  ON_VBXEVENT

  ON_VBXEVENT (wNotifyCode, memberFxn)

  Description:

  This macro is typically inserted through a message map ClassWizard, which function to indicate a message from the process control VBX. In the message the user is mapped to each of the map, a message handler's VBX control message should have a macro statement.

  RUNTIME_CLASS

  RUNTIME_CLASS (class_name)

  Description:

   Use this macro c ++ runtime class people get from the class structure. RUNTIME_CLASS specified by class_name returns a pointer to the class structure CRuntimeClass. Only DECLARE_DYNAMIC, DECLARE_DYNCREATE or DECLARE_SERIAL CObject defined before returning a pointer to the derived class CRuntimeClass a structure.

  THROW

  THROW (exception_object_pointer)

  Description:

  send the specified exception. THROW interrupt the operation of the program, the program passes control to the user associated CATCH block. If the user does not provide CATCH block, then control is passed to an MFC module, he prints out an error and terminates the operation.

  THROW_LAST

  THROW_LAST ()

  Description:

  This macro allows the user to send an exception of a local establishment. If a user tries to remove the unusual just discovered, so generally this exception will overflow and deleted. Use THROW_LAST, this exception is transferred directly to the next CATCH handler.

  TRACE

  TRACE (exp)

  Description:

   The formatted string to a dump device, e.g., a file, or debug monitor, and printf provide similar functionality. MS_DOS under the same procedures as printf C, TRACE macro is a tracking variable values at runtime convenient form. In the DEBUG environment, TRACE macro output to afxDump. In the Release version he does not do any work.

  Note:

  This macro is only valid in the DEBUG version of the MFC.

  TRACE0

  TRACE0 (exp)

  Description:

   and TRACE similar, but he tracking strings in the code segment, rather than DGROUP, so using less space DGROUP. TRACE0 tracking macro is a group of one variant, these macros can be used for debugging output. This group includes TRACE0, TRACE1, TRACE2 and TRACE3, these macros except that a different number of parameters taken. TRACE0 just take a format string may be used for simple text messages. TRACE1 take a formatted string plus a variable - to dump a variable. Similarly, TRACE2, TRACE3 were taken two or three parameters (strings after formatting). If the user in order to release the application, then only the data dump to afxDump.

  Note:

  This macro is only valid in the MFC DEBUG.

  TRACE1,

  TRACE1, (exp, the param1)

  Description:

  See TRACE0

  TRACE2

  TRACE2 (exp, the param1, param2)

  Description:

  See TRACE0

  TRACE3

  TRACE3 (exp, the param1, param2, Param3)

  Description:

  TRY

  TRY

  Description:

  With this establishment of a macro block TRY. TRY exclude a block of code identifying one exception. These CATCH exception handling in the subsequent block and AND_CATCH. Transmission is allowed: an external abnormality can pass TRY block or ignore them, or use THROW_LAST macros.

  The VERIFY

  the VERIFY (the BooleanExpression)

  Description:

   In DEBUG version of the MFC, VERIFY macro calculates the value of its variables. If the result is 0, the macro prints a diagnostic message and abort the program. If the condition is not 0, then what do not work. Diagnosis has the following form: assertion failed in file in line where name is the name of the source file, num is a failure in the source file line number aborted. In the Release version of MFC, VERIFY calculate the value of the expression but does not print or stop the program. For example: If the expression is a function call, then the call was successful.



Reproduced in: https: //www.cnblogs.com/userinterface/archive/2005/04/07/133140.html

Guess you like

Origin blog.csdn.net/weixin_33670713/article/details/93668149