Response Message and custom message in CB

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.