Topic: highlight objects on form

Hello Everyone,
I have an application that has a large number of objects on a form.
Because of this, I want to be able to indicate which object has focus to make it more user-friendly.
I have a small script to do this and it works fine except when there is a 'richtext' object which the script does not recognise.
The script currently is written with 'TDbEedit(sender) but it makes no difference if you use 'TRichEdit' (or anything else).
If you 'tab' through the fields on the form in the attached example (or click in any field using the mouse) you will see what the problem is.
Running on MVD 6.5 / SQLite / Windows11.
Does anyone have any ideas?
Thanks,
Derek.

Post's attachments

Attachment icon object underline.zip 456.88 kb, 19 downloads since 2025-06-11 

2 (edited by sparrow 2025-06-11 18:23:30)

Re: highlight objects on form

Hi Derek,

This is only part of the misunderstanding.
Suppose you place a Panel on the form and put several components on it. The coordinates of these components will be calculated from the anchor point of the Panel. There may also be problems with underlining. And not only the Panel... You can complicate the code and solve this.
Let's go back to RichEdit. This is a composite component (edit window, three menus ...) and apparently not fully described correctly in the source code. Sad.
But in this case you can get around it like this:

procedure highlighter (Sender: TObject);
var
  TctrlS: TControl;
begin
  if Sender.classname = 'TRichViewEdit' then
    TctrlS := TControl(Sender).parent else
      TctrlS := TControl(Sender);

  form1.label0.Width := TctrlS.width - 2;
  form1.label0.Left  := TctrlS.left + 1;
  form1.label0.top   := TctrlS.top + TctrlS.height;
end;

The point of the solution is that for the RichEdit component editing window we find the owner of this window, which is 'RichEdit1'.
Unfortunately, clicking on the RichEdit menu will not work.

Re: highlight objects on form

Hi Sparrow,
Thanks for the fix.
I knew about the issue with 'panels' (it's the same for 'group boxes' as well) but they are not used in my application (at the moment!).
Regards,
Derek.

4 (edited by sparrow 2025-06-11 20:08:23)

Re: highlight objects on form

Derek, your idea is interesting.


Components on Panel, GroupBox, PageControl are supported.

Post's attachments

Attachment icon object underline m.zip 123.61 kb, 19 downloads since 2025-06-11 

Re: highlight objects on form

or

Post's attachments

Attachment icon object underline m1.zip 124.04 kb, 20 downloads since 2025-06-11 

Re: highlight objects on form

Hi Sparrow,
Thanks for the updates - nice.
Instead of using your 'shape' procedure, another option might be to use the existing label (a label will always sit in the background by default) and just alter it's size so that it creates the effect of a border around each object.
Which ever method is used, I think it now highlights each object very well.
Derek.

Post's attachments

Attachment icon object underline m2.zip 458.54 kb, 30 downloads since 2025-06-12