Develop editing controls with history of history with C ++ Builder

zhaozj2021-02-08  229

Home: http://www.maxss.net email: maxchou@163.com

By developing this component, you can learn: * Capture Windows Message * Develop Custom BCB Components * Learn more VCL's knowledge before doing graduation is in order to achieve a similar function, while preparing a deeper learning component, I have been developed. Some problems have been found here, and later solved by reading the source code of VCL. This article has targetedly introduced components development in BCB, hoping to inspire everyone. This is now called this THISTORYEDIT has been added to the interface classification of my MaxSpace Studio Component Library (MSSCL), which is a BCB component package I offer, and all source code is available. To learn more about this component library, please visit the C / C column of my homepage: http://www.maxss.net/cc As for the creation of components in C Builder, please see another article "Use C Builder Some questions when creating custom VCL components "Because this component is the main role or data input, just add a function that can record the input history, so I will directly inherit a new class directly from the TCUStomedit class, I am here Call it for this THISTORYEDIT, and there is another list object for saving input history, I divide it into two objects, one is used to store input history, the other is to display input history and interact with the user. So, I chose to use TStringList to store input history, with TListBox to display the input history and interact with the user, use the design idea of ​​the object combination to use it as a member variable of this THISTORYETIT. Then you will define a unique properties, methods, and events for it. Although input history is only used as internal data, in order to provide the component to provide more practical features, I have designed a TStringsList type property History, which can read all input history content. Considering that the input history may have the need for storage and reproduction, I have designed two methods, which are loadFromfile (filename) and SaveTofile (filename), which implements saves the input history with INI's file format. Reproduce. Also add an onhistoryListBoxShow event, which triggers this event when you enter the historical box appears, so this THISTORYET has already designed a relatively perfect and flexible feature. Then there are some details of the details. Such as the creation of the combination object, message processing, and internal program logic, etc. To create a combined object from the components inherited from TControl, such as THistROL :: setParent (TWINCONTROL * APART) if you interact with the user, if you do not overload the function, if you do not overload the function An error cannot be found when you create a THISTORYEDIT object. Get the focus and edit the contents of the EditEit to display the input history box (if the number of entered history is greater than 0), or when the focus is lost, enter the history list should disappear (if it is displayed), so capture these related Windows messages. (WM_SETFOCUS, WM_KILLFOCUS ...) is processed. This article will be written here first, everyone looks at the source code and controls the above design to understand the THISTORYEDIT.

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

New Post(0)