In Borland C++builder, you can also respond to messages as you would in Delphi, but it just looks a little bit more complicated. For messages that are already defined by the system, you can respond directly, whereas non-system messages can be customized as follows:
//The following code is written in the header file:
#define WM_MY_OPEN_CMDLINE_FILE (wm_user+1)//interprocess communication custom Messages
#define WM_MY_SEARCH_NODE ( Wm_user+2//Find custom messages for commands
Class Tsomeform:public Tform
{//Form class definition
//... Other code in the class
Protected:
//message response process
void __fastcall opencmdlinefile (tmessage messages);
void __fastcall Searchdocumentnode (tmessage message);
void __fastcall getwindowminmaxinfo (Twmgetminmaxinfo message);
//Implement the correct response for the message through the following macro definition
Begin_message_map
Message_handler (Wm_my_open_cmdline_file, Tmessage, Opencmdlinefile)
Message_handler (Wm_my_search_node, Tmessage, Searchdocumentnode)
Message_handler (WM_ Getminmaxinfo, Twmgetminmaxinfo, Getwindowminmaxinfo)
End_message_map (tform)
};//end class
------------- -------------------------------------------------------------------
//Below is the implementation code, written in the module file:
void __fastcall Tsomeform::opencmdlinefile (Tmessage message)
{//pass parameters directly through the messaging structure
LPSTR lpcmdline= (LPSTR) message.lparam;// Gets the parameter from the message
This->handlecmdlinefile (lpcmdline);/Handle LifeThe argument to the row
return;
}
--------------------------------------------------------------------------------
void __fastcall Tsomeform::searchdocumentnode (Tmessage message) The parameters in the
{//Response lookup messages
//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;
minmaxinfo->ptmintracksize.y=300;
return;
}
Where: the definition of tmessage and Twmgetminmaxinfo types can be seen: C:\Program files\borland\cbuilder\inlucde\vcl\messages.hpp, and other message response methods are the same.
In addition, you can define a corresponding message structure for a custom message (such as: Tsearchnode_message), as to how to define the message structure, you can refer to the source code of Borland: C:\Program files\borland\cbuilder\ Inlucde\vcl\messages.hpp