In Borland C ++ builder, you can also respond to messages like in Delphi, but it looks a little more complicated. You can directly respond to messages that have been defined by the system, instead of custom messages that are not defined as follows:
// The followingCodeWritten in the header file:
# Define wm_my_open_cmdline_file (wm_user + 1) // custom message for inter-process communication
# Define wm_my_search_node (wm_user + 2) // find the custom message of the command
Class tsomeform: Public tform
{// Class definition of a form
// Other code in the... class
Protected:
// Response Process of the message
Void _ fastcall openjavaslinefile (tmessage message );
Void _ fastcall searchdocumentnode (tmessage message );
Void _ fastcall getwindowminmaxinfo (twmgetminmaxinfo message );
// Use the following macro definition to correctly respond to messages
Begin_message_map
Message_handler (wm_my_open_cmdline_file, tmessage, opendomainlinefile)
Message_handler (wm_my_search_node, tmessage, searchdocumentnode)
Message_handler (wm_getminmaxinfo, twmgetminmaxinfo, getwindowminmaxinfo)
End_message_map (tform)
}; // End class
--------------------------------------------------------------------------------
// The following code is written in the module file:
Void _ fastcall tsomeform: opendesklinefile (tmessage message)
{// This article from C ++ builder research-http://www.ccrun.com/article.asp? I = 227 & D = 3ae1go
{// PASS Parameters directly through the message structure
Lpstr lpcmdline = (lpstr) message. lparam; // obtain parameters from message
This-> handledomainlinefile (lpcmdline); // process command line parameters
Return;
}
--------------------------------------------------------------------------------
Void _ fastcall tsomeform: searchdocumentnode (tmessage message)
{// Response query message
// Parameters in message are not required here.
This-> searchnode ();
Return;
}
--------------------------------------------------------------------------------
Void _ fastcall tsomeform: getwindowminmaxinfo (twmgetminmaxinfo message)
{// Set the minimum size of the Main Window
Minmaxinfo * minmaxinfo = message. minmaxinfo;
Minmaxinfo-> ptmintracksize. x = 400;
Min maxinfo-> ptmintracksize. Y = 300;
Return;
}
For definitions of tmessage and twmgetminmaxinfo types, see C:/program files/Borland/cbuilder/inlucde/VCL/messages. HPP. Other message response methods are the same.
In addition, you can define a corresponding message structure (for example, tsearchnode_message) for custom messages. For how to define the message structure, refer
Borland'sSource code: C:/program files/Borland/cbuilder/inlucde/VCL/messages. HPP