Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Standard Controls/TEdit    [ Add a report in this area ]  
Report #:  55252   Status: Closed
cursor (caret) disappears in second forms TEdit, when main form below has a dbgrid
Project:  Delphi Build #:  11.0.2804.9245
Version:    11.0 Submitted By:   Christoph Rabsch
Report Type:  Basic functionality failure Date Reported:  11/25/2007 11:32:31 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   265902
Resolution: Duplicate (Resolution Comments) Resolved in Build: : 12.0.3268.18535
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
The cursor (caret) disappears in a TEdit-Field in a form, when the calling form has a focused dbgrid. Depending on the position where the second (called) form is shown, the cursor disappears immediately or when the form is moved over the dbgrid.
Steps to Reproduce:
Create a mainform with a dbgrid. Set it active so that it shows any data-lines. Use a speedbutton or a menu to show a second form with a TEdit field.
The cursor (caret) is not visible in the TEdit-field. If it is visible anyway, the second form hides the actual cursor-position in the dbgrid below. Move the second form and the caret will disappear, when you can see the active cursor-position in dbgrid below.
Workarounds
The problem is, that the caret is set to a new position in 'TCustomGrid.Paint' in the procedure 'DrawCells' (line 1863, grids.pas). This code is executed although the main form (where the dbgrid is placed on) is not active. Cause SetCaret applies to the active Form, the caret is shown in the Tedit-field in the second form with a y-coordinate that refers to the position in the dbgrid (e.g. y=18). Until you type a charater in the Tedit-field this position will not be corrected and the caret is invisible.

Workaround: Who has no access to the vcl (grids.pas) can set the focus on an other TWinControl before showing the the second form.

Solution: Add a condition to the second if-statement in TCustomGrid.IsActiveControl (grids.pas).

Original Source code in line 1443 (grids.pas):

if (ParentForm.ActiveControl = Self) then

My code:

if (ParentForm.ActiveControl = Self) and (ParentForm.Active) then
Attachment
None
Comments

Jens Doll at 12/8/2011 10:05:02 AM -
The problem seems to remain in RAD Studio 8.0. I've got two forms and when the second one gets the focus, the first one, containing a TRichEdit, cannot be focussed again and does not show it's caret.

Tomohiro Takahashi at 12/8/2011 5:41:09 PM -
> The problem seems to remain in RAD Studio 8.0.  ...
Could you please put new QC report about your issue?

Server Response from: ETNACODE01