I am using Eye candy controls for user interface.
To display the current state of the sliders at moving the slider, I use a TPanel (pnHint) with a TLabel (lbHint) on it (see screenshot, the cursor isn't shown in the capture, but I was at moving the slider as the capture is done). Both TPanel and TLabel are set to Autosize. When TLabel is set to Visible := False, the TPanel isn't visible.
Here is the code that displays the label:
procedure TfrmMain.slSliderChange(Sender: TObject);
var
pt: TPoint;
ctrl: TControl;
begin
pt := ScreenToClient(Mouse.CursorPos);
lbHint.Caption := IntToStr(trunc(TECSlider(Sender).Position));
ctrl := ControlAtPos(pt, [capfRecursive, capfAllowWinControls]);
if Assigned(ctrl) then
begin
pnHint.Left := ctrl.Left + ctrl.Width - lbHint.Width
end
else
pnHint.Left := pt.Y;
pnHint.Top := pt.Y;
//pnHint.BringToFront;
lbHint.Visible := True;
end;
procedure TfrmMain.slSliderMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
lbHint.Visible := False;
end;
As it can be seen, the panel and label follows the cursor (which is nice), but if the slider is moved too fast - there are redrawing artifacts (ghosts).
Any advices what can be optimized here?
Using Hints from the controls isn't a solution.