diff --git a/packages/delphi11/heidisql.dpr b/packages/delphi11/heidisql.dpr
index 918c0297..63e7417b 100644
--- a/packages/delphi11/heidisql.dpr
+++ b/packages/delphi11/heidisql.dpr
@@ -38,7 +38,8 @@ uses
editvar in '..\..\source\editvar.pas' {frmEditVariable},
view in '..\..\source\view.pas' {frmView},
selectdbobject in '..\..\source\selectdbobject.pas' {frmSelectDBObject},
- memoeditor in '..\..\source\memoeditor.pas' {frmMemoEditor};
+ memoeditor in '..\..\source\memoeditor.pas' {frmMemoEditor},
+ grideditlinks in '..\..\source\grideditlinks.pas';
{$R *.RES}
diff --git a/packages/delphi11/heidisql.dproj b/packages/delphi11/heidisql.dproj
index fa473e4b..0c8f8917 100644
--- a/packages/delphi11/heidisql.dproj
+++ b/packages/delphi11/heidisql.dproj
@@ -94,6 +94,7 @@
+
diff --git a/source/childwin.pas b/source/childwin.pas
index 230246b4..840e90aa 100644
--- a/source/childwin.pas
+++ b/source/childwin.pas
@@ -577,7 +577,7 @@ uses
Main, fieldeditor,
copytable, sqlhelp, printlist,
column_selection, data_sorting, runsqlfile, mysql_structures,
- Registry, memoeditor;
+ Registry, grideditlinks;
type
diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas
new file mode 100644
index 00000000..ebb1a273
--- /dev/null
+++ b/source/grideditlinks.pas
@@ -0,0 +1,128 @@
+unit grideditlinks;
+
+// The editor links, instanciated by VirtualTree.CreateEditor
+
+interface
+
+uses Windows, Graphics, messages, VirtualTrees, memoeditor;
+
+type
+ TMemoEditorLink = class(TInterfacedObject, IVTEditLink)
+ private
+ FForm: TfrmMemoEditor;
+ FTree: TCustomVirtualStringTree; // A back reference to the tree calling.
+ FNode: PVirtualNode; // The node to be edited.
+ FColumn: TColumnIndex; // The column of the node.
+ FTextBounds: TRect; // Smallest rectangle around the text.
+ FStopping: Boolean; // Set to True when the edit link requests stopping the edit action.
+ public
+ FieldType: Integer;
+ MaxInputLength: Integer;
+ constructor Create;
+ destructor Destroy; override;
+ function BeginEdit: Boolean; virtual; stdcall;
+ function CancelEdit: Boolean; virtual; stdcall;
+ function EndEdit: Boolean; virtual; stdcall;
+ function GetBounds: TRect; virtual; stdcall;
+ function PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; stdcall;
+ procedure ProcessMessage(var Message: TMessage); virtual; stdcall;
+ procedure SetBounds(R: TRect); virtual; stdcall;
+ end;
+
+
+implementation
+
+
+constructor TMemoEditorLink.Create;
+begin
+ inherited;
+end;
+
+destructor TMemoEditorLink.Destroy;
+begin
+ inherited;
+ FForm.Free;
+end;
+
+
+function TMemoEditorLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall;
+// Retrieves the true text bounds from the owner tree.
+var
+ Text: WideString;
+ F: TFont;
+begin
+ Result := Tree is TCustomVirtualStringTree;
+ if not Result then
+ exit;
+
+ FTree := Tree as TVirtualStringTree;
+ FNode := Node;
+ FColumn := Column;
+
+ // Initial size, font and text of the node.
+ F := TFont.Create;
+ FTree.GetTextInfo(Node, Column, F, FTextBounds, Text);
+
+ // Create the editor form
+ FForm := TfrmMemoEditor.Create(Ftree);
+ FForm.Parent := Tree;
+ FForm.memoText.Font := F;
+ FForm.memoText.Text := Text;
+end;
+
+
+function TMemoEditorLink.BeginEdit: Boolean; stdcall;
+begin
+ Result := not FStopping;
+ if Result then
+ FForm.Show;
+end;
+
+
+function TMemoEditorLink.CancelEdit: Boolean; stdcall;
+begin
+ Result := not FStopping;
+ if Result then begin
+ FStopping := True;
+ FForm.Hide;
+ FTree.CancelEditNode;
+ end;
+end;
+
+
+function TMemoEditorLink.EndEdit: Boolean; stdcall;
+begin
+ Result := not FStopping;
+ if Result then try
+ FStopping := True;
+ if FForm.memoText.Text <> FTree.Text[FNode, FColumn] then
+ FTree.Text[FNode, FColumn] := FForm.memoText.Text;
+ FForm.Hide;
+ except
+ FStopping := False;
+ raise;
+ end;
+end;
+
+
+function TMemoEditorLink.GetBounds: TRect; stdcall;
+begin
+ Result := FForm.BoundsRect;
+end;
+
+
+procedure TMemoEditorLink.ProcessMessage(var Message: TMessage); stdcall;
+begin
+end;
+
+
+procedure TMemoEditorLink.SetBounds(R: TRect); stdcall;
+begin
+ // Sets the top left corner of the edit control
+ if not FStopping then
+ FForm.TopLeft := R.TopLeft;
+end;
+
+
+
+end.
diff --git a/source/memoeditor.pas b/source/memoeditor.pas
index ffd62f06..3a6ce986 100644
--- a/source/memoeditor.pas
+++ b/source/memoeditor.pas
@@ -3,8 +3,7 @@ unit memoeditor;
interface
uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, TntStdCtrls, Registry, VirtualTrees;
+ Windows, Classes, Graphics, Controls, Forms, StdCtrls, TntStdCtrls, Registry;
{$I const.inc}
@@ -21,31 +20,6 @@ type
end;
- // The editor link, instanciated by VirtualTree.CreateEditor
- TMemoEditorLink = class(TInterfacedObject, IVTEditLink)
- private
- FForm: TfrmMemoEditor;
- FTree: TCustomVirtualStringTree; // A back reference to the tree calling.
- FNode: PVirtualNode; // The node to be edited.
- FColumn: TColumnIndex; // The column of the node.
- FTextBounds: TRect; // Smallest rectangle around the text.
- FStopping: Boolean; // Set to True when the edit link requests stopping the edit action.
- public
- FieldType: Integer;
- MaxInputLength: Integer;
- constructor Create;
- destructor Destroy; override;
- function BeginEdit: Boolean; virtual; stdcall;
- function CancelEdit: Boolean; virtual; stdcall;
- function EndEdit: Boolean; virtual; stdcall;
- function GetBounds: TRect; virtual; stdcall;
- function PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; stdcall;
- procedure ProcessMessage(var Message: TMessage); virtual; stdcall;
- procedure SetBounds(R: TRect); virtual; stdcall;
- end;
-
-
-
implementation
uses main, helpers;
@@ -84,95 +58,5 @@ begin
end;
-constructor TMemoEditorLink.Create;
-begin
- inherited;
-end;
-
-destructor TMemoEditorLink.Destroy;
-begin
- inherited;
- FForm.Free;
-end;
-
-
-function TMemoEditorLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall;
-// Retrieves the true text bounds from the owner tree.
-var
- Text: WideString;
- F: TFont;
-begin
- Result := Tree is TCustomVirtualStringTree;
- if not Result then
- exit;
-
- FTree := Tree as TVirtualStringTree;
- FNode := Node;
- FColumn := Column;
-
- // Initial size, font and text of the node.
- F := TFont.Create;
- FTree.GetTextInfo(Node, Column, F, FTextBounds, Text);
-
- // Create the editor form
- FForm := TfrmMemoEditor.Create(Ftree);
- FForm.Parent := Tree;
- FForm.memoText.Font := F;
- FForm.memoText.Text := Text;
-end;
-
-
-function TMemoEditorLink.BeginEdit: Boolean; stdcall;
-begin
- Result := not FStopping;
- if Result then
- FForm.Show;
-end;
-
-
-function TMemoEditorLink.CancelEdit: Boolean; stdcall;
-begin
- Result := not FStopping;
- if Result then begin
- FStopping := True;
- FForm.Hide;
- FTree.CancelEditNode;
- end;
-end;
-
-
-function TMemoEditorLink.EndEdit: Boolean; stdcall;
-begin
- Result := not FStopping;
- if Result then try
- FStopping := True;
- if FForm.memoText.Text <> FTree.Text[FNode, FColumn] then
- FTree.Text[FNode, FColumn] := FForm.memoText.Text;
- FForm.Hide;
- except
- FStopping := False;
- raise;
- end;
-end;
-
-
-function TMemoEditorLink.GetBounds: TRect; stdcall;
-begin
- Result := FForm.BoundsRect;
-end;
-
-
-procedure TMemoEditorLink.ProcessMessage(var Message: TMessage); stdcall;
-begin
-end;
-
-
-procedure TMemoEditorLink.SetBounds(R: TRect); stdcall;
-begin
- // Sets the top left corner of the edit control
- if not FStopping then
- FForm.TopLeft := R.TopLeft;
-end;
-
end.