Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-12

TCustomControl and Z-order problem

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

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

Reply by email

Bart
to Bart

On 12/25/14, Bart wrote:

(Second attempt to post)

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.

On further investigation it seems even more weird to me. The TEdit is always drawn on top of the new TCustomControl, but the new TCustomControl recieves mouseclicks if you click on the area where it should be painted.

In the mean time i also checked QT-Linux, and there it works as (I) expected.

So, is it a GTK2 bug?
(I guess its a bug in my code though.)

See attached sample project.

Upon startup there should be a grayed-out text visible in front of the TTHEdit and (unfortunately) in front of Panel2.
If you click on the text, it disappears.
It'll re-appear if you leave the TTHEdit and the TTHEdit is empty (Text = '').

On GTK2 the "overlay" is painted behind the TTHEdit (this control is created at runtime) and behind Panel2.
On Win32 it is painted in front of the TTHEdit and in front of Panel2 (the latter is unwanted (but expected), and needs to be fixed somehow).

Bart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.zip
Type: application/zip
Size: 69393 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20141226/32a74fff/attachment-0001.zip>

Reply by email