Custom control highlighting

Discussion related to the Cross Codebot open source framework
sysrpl
Posts: 108
Joined: Thu Feb 05, 2015 6:31 pm

Custom control highlighting

Postby sysrpl » Fri Apr 03, 2015 6:07 pm


This article is describes how to create a cross platform custom control highlighter. Here is the example application for we'll be working towards:



A control highlighter is a user definable color border which can be placed on controls. The highlighter can be any shape, color, or transparency. It appears above a form and follows a control whether it is moved, resized, or changes visibility.

To use a control highlighter simply create a TControlHighligher object and link it to a control:

var
Highlighter: TControlHighlighter;

procedure TForm1.Button1Click(Sender: TObject);
begin
{ Create the highlighter }
Highlighter := TControlHighlighter.Create(Self);
{ Highlight an edit box }
Highlighter.Control := Edit1;
{ Turn highlighter on or off using the visible property }
Highlighter.Visible := True;
end;


You can also adjust the highlighter style:

{ Make the highlights in blue }
Highlighter.Color := clBlue;
{ Make the highlighter really thick }
Highlighter.Thickness := 10;
{ Use a rectangle instead of a round rectangle }
Highlighter.Radius := 0;
{ Appear 2px from the borders of the control }
Highlighter.Offset := 2;
{ Mostly transparent }
Highlighter.Opacity := $30;

Return to “Cross Codebot”

Who is online

Users browsing this forum: No registered users and 2 guests

cron