[Lazarus] TCustomControl and Z-order problem

Bart bartjunk64 at gmail.com
Thu Dec 25 23:58:38 CET 2014


Hi,

I create a TCustomControl descendant and @runtime I position it at the
exact position of anoher control (TEdit) then set it's parent to the
other controls parent (the same form in this case).
On Windows, the new control is drawn over the TEdit (as I want,
probably just by luck), but on GTK2 it is drawn behind the TEdit.

BringToFront does not help.

Obviously I'm doing something wrong here, but what.

The code looks something like this:

procedure TTextHintOverlay.ShowOverlay;
var
  BRect: TRect;
begin
  if not CanShow then Exit;  //before you ask, CanShow is True, I checked
  BRect := FEdit.BoundsRect;
  if FEdit.BorderStyle = bsSingle then InflateRect(BRect, -2, -2);
  BoundsRect := BRect;
  ....
  Parent := FEdit.Parent;  //Form1 in this case
  Visible := True;
  BringToFront;
end;

I thought it might have to do with the order in which events are
handled, but even when I later find the component on the form and do
BringToFront it does not work.
I also tried to do SendToBack on the TEdit, but to no avail.

Any thoughts?

Bart




More information about the Lazarus mailing list