From 7e2897ebcf93e6f945284a55fd29b00f43a08328 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 26 Aug 2008 05:56:43 +0000 Subject: [PATCH] Fix bug #696 Problem with popup editor editing the last record. Solution: Always center the memo editor within the grid. --- source/grideditlinks.pas | 4 +--- source/memoeditor.pas | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas index 0ad5dda7..9dd4988d 100644 --- a/source/grideditlinks.pas +++ b/source/grideditlinks.pas @@ -171,9 +171,7 @@ 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; + // See OnFormShow in the form object itself end; diff --git a/source/memoeditor.pas b/source/memoeditor.pas index cef19c7a..ce1dbad8 100644 --- a/source/memoeditor.pas +++ b/source/memoeditor.pas @@ -29,7 +29,6 @@ type { Private declarations } public { Public declarations } - TopLeft: TPoint; // Used to position this form on the top left corner of the edited cell end; @@ -55,15 +54,18 @@ end; procedure TfrmMemoEditor.FormShow(Sender: TObject); +var + Tree: TCustomVirtualStringTree; begin + Tree := TCustomVirtualStringTree(Parent); // Hide window caption SetWindowLong(Handle, GWL_STYLE, GetWindowLong( Handle, GWL_STYLE ) and not WS_CAPTION ); // Restore form dimensions Width := Mainform.GetRegValue(REGNAME_MEMOEDITOR_WIDTH, DEFAULT_MEMOEDITOR_WIDTH); Height := Mainform.GetRegValue(REGNAME_MEMOEDITOR_HEIGHT, DEFAULT_MEMOEDITOR_HEIGHT); - // Set top left corner to match the edited cell - Left := TopLeft.X; - Top := TopLeft.Y; + // Center the form in the grid + Left := (Tree.Width - Width) div 2; + Top := (Tree.Height - Height) div 2; // Fix label position: lblTextLength.Top := tlbStandard.Top + (tlbStandard.Height-lblTextLength.Height) div 2; SetWindowSizeGrip(Handle, True);