Run-time Designer
This document contains the documentation of the current version of Run-time Designer.
Version: 2.0.10.26
Version date: 2000-07-19
Copyright©
Copyright© 1998-2000 Karl-Otto Rosenqvist. This component is freeware without source. It may be distributed with any component package or application. The source code is not freeware and should therefore not be redistributed without my permission. This component is distributed "as is" and may contain errors. I will not take any responsebillity of any damage caused directly or indirectly by Run-time Designer.
Contacting me...
To contact me send an e-mail to towebo@telia.com. To find the latest versions and the newest information about Run-time Designer pelase go to http://welcome.to/towebo.
Class TRTDesigner
The Run-time Designer is a non-visible component that makes it possible to edit forms at run-time. The EditMode property decides if the component is in edit mode or not. Then property BaseControl specifies wich TWinControl decendant is the editing area.
AcceptedControls | EditMode | Options |
Active | GrabHandleKind | UndoKind |
BaseControl | GridX | UndoLimit |
Control | GridY | UndoString |
Controls | KeySupportOptions |
Class TDesignServer
Unit variables
DesignServer : TDesignServer;
Function RuntimeDesignerVersionStr : String;
This function returns the Run-time Designers version in the following format:
majorVersion.minorVersion.release.build
// TRTDesign ---------------------------------------------------------------------
Property AcceptedControls : TList;
If you want to restrict the editing to only some controls on the BaseControl you just add them to this list. Example: RTDesigner1.AcceptedControls.Add(Button1);
Property Active : Boolean;
This is a read-only property that you normally don't need to access. It is used internally by the DesignServer to check if the TRTDesigner is in EditMode and its parent form is the active form.
Property BaseControl : TWinControl;
The BaseControl property is very important, it's the heart of
RTDesigner. You can set this property either design-time or run-time.
When the BaseControl is changed the undo list is reset. The
BaseControl can be set to any TWinControl on a form or to a form
itself. To set the form as BaseControl specify the form's name as
BaseControl.
Everything on the BaseControl is moveable, sizeable and
deleteable except if you are using the AcceptedControls property.
Property Control[index : Integer] : TControl;
This property is used to access the selected controls.
Property Controls : TList;
This is the list to wich all selected controls are added. You normally don't have to use it.
Property EditMode : Boolean;
When you want the controls on the BaseControl to be editable set the EditMode to True, and if you want the controls to act normally set to False.
Property GrabHandleKind : TGrabHandleKind;
This property affects the look of the grab handles used to show the selection and to size controls.
gkHighContrast | When GrabHandleKind set to gkHighContrast the grabhandles is white with a black frame that always makes it visible. |
gkDelphi | The grabhandles looks just as they do in the Delphi IDE, black when selected one control, when selected multiple controls they are gray. |
gk3D | The grabhandles has a nice 3D look. |
Property GridX : Integer;
Specifies the grid spacing in X-order.
Property GridY : Integer;
Specifies the grid spacing in Y-order.
Property KeySupportOptions : TKeySupportObject;
This property was made so that You can choose wich control keys should be held down to get the wished result.
TKeySupportOptions = (ksoNotActive, ksoActive, ksoCtrl, ksoAlt, ksoCtrlAlt);
Key | Function |
A | Select all |
C | Copy to clipboard |
Del | Delete selected controls |
Ins | Fire the OnInsertQuery event |
N | Deselect all controls |
V | Paste from clipboard |
X | Cut to clipboard |
Z | Undo |
Property Options : TRTDOptions;
The Run-time Designers options specifies how it behaves. Inclode or exclude any option to change the behavior of the TRTDesigner.
rtdProportionalSizing | When grabbing the corner handles the control is sized proportionally. |
rtdCenterSizing | When sizing a controls height, it grows both uppwards and downwards. This option is often used when creating flow-chart applications. |
rtdPropertiesMenuItem | Not yet implemented, but will add a "Properties" menu item to the designer popup menu. |
rtdSnapToGrid | When you size or move controls they snap to the grid to make it easier to place them correctly to eachother. |
Property UndoKind : TUndoKind;
This property is used to determine what kind of undo operation is the currently the next.
ukNone | There is nothing to undo. |
ukMove | The last action that was added to the undo list was a move. |
ukSize | The last action that was added to the undo list was a sizing. |
ukPropertiesChanged | This undo kind is set when you manually add something to the undo list. |
ukDelete | The last action that was added to the undo list was a deletion. |
ukInsert | The last action that was added to the undo list was a insert. |
Property UndoString : String;
This text is ment to be the caption of the Undo menu item. It reflects what will happen when the user undones.
Procedure AddToSelection(aControl : TControl);
This method adds aControl to the list of selected controls. Useful if You want to programatically select some controls.
TUndoKind = (ukNone, ukMove, ukSize, ukPropertiesChanged, ukDelete, ukInsert);
Procedure AddUndo(Kind : TUndoKind);
Normally you don't need to call this method but if you or the user change some properties and you want to make it possible to undo it call AddUndo(ukPropertiesChanged); and all the selected controls and their proerties is stored in the undo list. At this time it isn't possible to customize the UndoString.
Procedure AlignToGrid;
To align all the selected controls to the grid call AlignToGrid. This is done internally when selecting Align to grid in the designer popup menu.
Procedure BringToFront;
Calling BringToFront, wich is done internally when selecting Bring to front in the designer popup menu, all the selected controls will be brought to the front in Z-order beginning with Control[0]. This causes the Control[Controls.Count-1] to be the topmost control.
Procedure ClearBaseControl;
If you want to empty the BaseControl just call ClearBaseControl and it's clean.
Procedure CopyToClipboard;
To copy controls to be able to paste them later, call copy to clipboard. If AutoKeyboardSupport is True this method is called when the user presses Ctrl+C.
Procedure DeleteSelection;
This method does what it sounds like, it deletes all the selected controls. It's called internally when pressing Ctrl+Del and is also called when pressing Ctrl+X (cut to clipboard).
Function IsGrabHandle(aControl : TControl) : Boolean;
Use this method to check if a control is a grab handle. You should not process or save a grab handle! They are created and destroyed automatically.
Procedure LoadBCFromFile(const aFileName : String);
LoadBCFromFile opens the file specified in aFileName creates a stream and then calls LoadBCFromStream. This is the easy way to store the user's modifications to disk. Of course you can do this your self to take full control of the situation but I supply this as a bonus for all you who aren't so good on streaming.
Procedure LoadBCFromStream(Stream : TStream);
Here I load the BaseControl and its contents from the stream passed in the Stream variable.
Procedure PasteFromClipboard;
To paste the contents of the clipboard to the BaseControl call PasteFromClipboard. If AutoKeyboardSupport is True this method is called when the user presses Ctrl+V.
Procedure ResetUndo;
This method clears the undo list so the user cannot undo anything. ResetUndo is called when the BaseControl property is changed.
Procedure SaveBCToFile(const aFileName : String);
SaveBCToFile opens the file specified in aFileName creates a stream and then calls SaveBCToStream. This is the easy way to store the user's modifications to disk. Of course you can do this your self to take full control of the situation but I supply this as a bonus for all you who aren't so good on streaming.
Procedure SaveBCToStream(Stream : TStream);
Here I store the BaseControl and its contents to the stream passed in the Stream variable.
Procedure SelectAll;
When the user press Ctrl+A SelectAll is called. It adds all the controls contained in the BaseControl to the list of selected controls.
Function Selected(aControl : TControl): Boolean;
A fast way to check if a control is selected.
Procedure SelectNone;
When the user press Ctrl+N SelectNone is called. It clears the list of selected controls.
Procedure SendToBack;
Calling SendToBack, wich is done internally when selecting Send to back in the designer popup menu, all the selected controls will be sent to the back in Z-order beginning with Control[Controls.Count-1]. This causes the Control[0] to be the last control in the Z-order.
Procedure ShowSelection(Show : Boolean);
Use this method if You want to manipulate the visualization of the selection programmatically, mostly used internally.
Procedure Undo;
This is one of the key methods. It adds the abillity to undo changes made to controls contained in the BaseControl. Undo is called internally when the user clicks Ctrl+Z.
Procedure UpdateSelection;
UpdateSelection is used internally to set the position of the grab handles. If you move any selected control in your code you have to call UpdateSelection.
Property AfterBaseControlClear : TNotifyEvent;
This event occurs after the BaseControl has been cleared.
TAfterInsertEvent = Procedure(Sender : TObject;Control : TControl) of Object;
Property AfterInsert : TAfterInsertEvent;
The AfterInsert event occurs after a controlclass is returned in the OnInsertQuery event. This is a good time to set special property values.
Propery AfterMove : TNotifyEvent;
The AfterMove event occurs after one or more controls has been moved.
Property AfterSize : TNotifyEvent;
The AfterSize event occurs after the OnApplySize has returned True in variable ApplySize. At this time the control has the new bounds.
TSelectControlEvent = Procedure(Sender : TObject;Control : TControl;var DoSelect : Boolean) of Object;
Property BeforeSelectControl : TSelectControlEvent;
The BeforeSelectControl occurs before a control is added to the selection when the user clicks on it, makes a selectionframe around it, performs the command select all or pastes controls from the clipboard.
TApplySizeEvent = Procedure(Sender : TObject;SizedControl : TControl;oldBounds, newBounds : TRect;var ApplySize : Boolean) of Object;
Property OnApplySize : TApplySizeEvent;
The OnApplySize event occurs after the user has sized a control. oldBounds contains the control's bounds before the sizing started and newBounds is the bounds the control will get if ApplySize is True.
TBaseCtlClickEvent = Procedure(Sender : TObject;var ClearSelection, DrawSelectionFrame : Boolean;Shift : TShiftState;X, Y : Integer) of Object;
Property OnBaseControlClick : TBaseCtlClickEvent;
BaseControlClick happens when the user does a MouseDown on the
BaseControl with the left mouse button. The ClearSelection and
DrawSelectionFrame is by default True and determines if the
selection should be cleared and if there will be a frame drawn to
select controls.
Shift, X and Y works as they do in a normal MouseDown event.
TRTDDblClick = Procedure(Sender : TObject;Control : TControl) of Object;
Property OnDblClick : TRTDDblClick;
This event occurs whenever the user double clicks a component on the BaseControl.
TDeleteQueryEvent = Procedure(Sender : TObject;var DoDelete : Boolean) of Object;
Property OnDeleteQuery : TDeleteQueryEvent;
The OnDeleteQuery is launched when the user tries to delete the selected controls. Here you can ask him/her if he or she really wants to delete the controls.
Property OnEditModeChange : TNotifyEvent;
When the EditMode property is changed this event will be fired.
TGetPopupMenuEvent = Procedure(Sender : TObject;var Menu : TPopupMenu) of Object;
Property OnGetPopupMenu : TGetPopupMenuEvent;
This event is fired whenever a user clicks with the right mouse button on a control on the BaseControl. The Menu parameter is nil when entering this event and the only thing you need to do is to check for any conditions you want and then return the popupmenu that you think is suitable for this particular moment. If this event isn't assigned the OnPopuplateMenu event will be fired as in earlier versions.
TInsertEvent = Procedure(Sender : TObject;Control : TControl;var aClass : TControlClass) of Object;
Property OnInsertQuery : TInsertEvent;
This is one of the most important events for the application programmer. This event occurs every time the user clicks inside the BaseControl and it's a perfect opportunity to check if the user wants to create a new control. Example:
if ButtonClassSB.Down Then
aClass:=TButton
Else if EditClassSB.Down Then
aClass:=TEdit;
The variable aClass is by default nil.
Property OnKeyDown : TKeyEvent;
This standard KeyEvent occurs when the user press a key.
Property OnKeyUp : TKeyEvent;
This standard KeyEvent occurs when the user lets go of the key.
TRTDMouseEvent = Procedure(Sender : TObject;Control : TControl;Button : TMouseButton;Shift : TShiftState;X, Y : Integer) of Object;
Property OnMouseDown : TRTDMouseEvent;
When the user clicks on a control you have the power to do something. Control specifies the control the user clicks. Button, Shift, X and Y is just as in a normal MouseEvent.
TRTDMouseMove = Procedure(Sender : TObject;Control : TControl;Shift : TShiftState;X, Y : Integer;BaseControlCoords : TPoint) of Object;
Property OnMouseMove : TRTDMouseMove;
As the user moves the cursor over the BaseControl he or she fires this event lots of times. If the cursor is over a control Control points to this control. BaseControlCoords is a TPoint structure that contains the mouse position relative the BaseControl.
TRTDMouseEvent = Procedure(Sender : TObject;Control : TControl;Button : TMouseButton;Shift : TShiftState;X, Y : Integer) of Object;
Property OnMouseUp : TRTDMouseEvent;
When the user lets go of the mouse button over a control you have the power to do something. Control specifies the control the mouse is over. Button, Shift, X and Y is just as in a normal MouseEvent.
TPopulateMenuEvent = Procedure(Sender : TObject;var Menu : TPopupMenu) of Object;
Property OnPopulateDesignerMenu : TPopulateMenuEvent;
If you want to interact with the designer popup menu now is the time to do it. Example:
Menu.Items.Add(NewLine);
Menu.Items.Add(NewItem('This is only an example', 0, False, True, nil, 0, 'PopupMenuExample1'));
Menu.Items.Add(NewItem('how to use OnPopulateDesignMenu', 0, False, True, nil,
0, 'PopupMenuExample2'));
Note! This event is not fired if the OnGetPopupMenu event is assigned. It is recommended to use the newer OnGetPopupMenu event to make it easier when you want to change the appearence of the popup menu depending on the controls selected, time of day or maybe your current shoe size!
Property OnRemoveControl : TRemoveNotifyEvent;
TRemoveNotifyEvent = Procedure(Sender : TObject;aControl : TControl) of Object;
If You need to know when controls is removed from the BaseControl, just use this event.
Property OnUndoChange : TNotifyEvent;
Whenever something is undone or added to the undo list it fires this event so you have a chance to change the caption of a undo menu item and so on.
// TDesignServer ---------------------------------------------------------------------
Procedure AddDesigner(aDesigner : TRTDesigner);
AddDesigner is used internally when an application creates a Run-time Designer to keep track of where they are so they can get their messages. Do not use this method!
Procedure RemoveDesigner(aDesigner : TRTDesigner);
RemoveDesigner is used internally when an application destroys a Run-time Designer. Do not use this method!
Property OnActivate : TNotifyEvent;
This event occurs whenever the application is activated. Use this event instead of Application.OnActivate.
Property OnDeactivate : TNotifyEvent;
This event occurs whenever the application is deactivated. Use this event instead of Application.OnDeactivate.
Property OnMessage : TMessageEvent;
If you need to hook on the Application.OnMessage, don't! Hook on DesignServer.OnMessage instead, because if you steal the messages from the application Run-time Designer don't work!
This document was last updated on 21 february 1999.