| How to Add Size Handles to Controls being Resized at Run-Time | |||||||||||||||||||
| When you allow a user to move and resize controls on a Delphi form, at run-time using the mouse, to fully mimic the design-time environment, you should add eight size handles to the control being resized. Here's how. | |||||||||||||||||||
While in most situations you will arrange all the controls on a Delphi form in a "fixed" position, there are situations where you need to allow a user to change the placement and dimension of controls at run-time. Here's how to enable dragging and resizing controls with mouse, while the application is running.
Sizing handles code by Alan Evans, article text by Zarko Gajic
In theory... Eight Size Handles... in practice ![]() The overriden Create constructor calls the CreateNodes function:
CreateNodes in short: a private FNodes variabe of type TObjectList is added to the form (and instantiated in the Create constructor): FNodes := TObjectList.Create(False); Each of the 8 panels is assigned 3 mouse related event handling procedures (NodeMouseDown, NodeMouseMove, NodeMouseUp) that track which control is being resized and provide the programming logic to size the control. Download the sample application and try for yourself Key presses being processed for TCustomeEdit / TCustomMemo descendants? 1. Set Form1.KeyPreview to TRUE (either using Object Inspector or from code)
Note: A form's KeyPreview property determines whether form keyboard events are invoked before component keyboard events. The form can receive any keystrokes that the focused component can receive. To trap keystrokes at the form level instead of passing them to the form's components, set the form's KeyPreview property to True. If you need any kind of help at this point, please post to the Delphi Programming Forum where all the questions are answered and beginners are treated as experts. Next part > Dynamically swap event handling procedures > Part 1, 2, 3 |
|||||||||||||||||||

