Recent

Author Topic: image above of panels  (Read 4103 times)

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
image above of panels
« on: April 25, 2017, 07:18:11 pm »
hi my friends, How can i put an image on top of several panels ?

PD: Attached project and images

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: image above of panels
« Reply #1 on: April 25, 2017, 07:42:06 pm »
It depends how your image is drawn.
If it is a TImage, then image.BringToFront;
should do it.

balazsszekely

  • Guest
Re: image above of panels
« Reply #2 on: April 25, 2017, 07:53:18 pm »
@howardpc

TImage is inherited from TGraphicControl not TWinControl so it won't behave like a window. Calling BringToFront will have no effect, the Z order is not changed(see screenshot).
Personally I would go with a transparent panel. Implementing it is a non-trivial operation especially if it has to be cross platform.

sky_khan

  • Guest
Re: image above of panels
« Reply #3 on: April 25, 2017, 09:13:26 pm »
I'm a genius!!! :D

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: image above of panels
« Reply #4 on: April 25, 2017, 09:21:29 pm »
I'm a genius!!! :D

well done! now animate this and replace it with a gif with key color transparency  :D

balazsszekely

  • Guest
Re: image above of panels
« Reply #5 on: April 25, 2017, 10:30:10 pm »
This is particularly hard because of the panels. Anyway I attach a windows only solution. Lets hope somebody come up with a better idea.
« Last Edit: April 25, 2017, 10:31:57 pm by GetMem »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: image above of panels
« Reply #6 on: April 25, 2017, 11:38:14 pm »
Here's a quick 2-liner in which the image is repainted in the Panels' OnPaint with an offset according to the image position.  (Can be refined with ClientToScreen etc...)
« Last Edit: April 26, 2017, 12:11:29 am by wp »

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: image above of panels
« Reply #7 on: April 26, 2017, 01:50:34 am »
Thanks to all friends  :), I tried the example of "wp" and works on windows and linux.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel2Paint(Sender: TObject);  // here link the panel1 y panel2 in Paint event
  2. var
  3.   P: TPoint;
  4. begin
  5.   P := Point(Image1.Left - TControl(Sender).Left, Image1.Top - TControl(Sender).Top);
  6.   TPanel(Sender).Canvas.Draw(P.X, P.Y, Image1.Picture.Bitmap);
  7. end;
  8.  
For now work fine. thanks very much  :) :)

balazsszekely

  • Guest
Re: image above of panels
« Reply #8 on: April 26, 2017, 05:33:15 am »
@wp

Nice. Thanks for sharing it! I believe I overthink this problem  :D

 

TinyPortal © 2005-2018