Recent

Author Topic: SOLVED: Bring TImage to front of TEdit  (Read 1061 times)

SaraT

  • Jr. Member
  • **
  • Posts: 86
  • A little student
SOLVED: Bring TImage to front of TEdit
« on: February 13, 2020, 09:33:40 pm »
Hi friends
Is there a way to bring an Image control to front?

This doesn't work: Image1.BringToFront; neither Z-order property.

Please, can you provide me a new trick? :)
See the attached image.
« Last Edit: February 14, 2020, 02:08:43 am by SaraT »

winni

  • Hero Member
  • *****
  • Posts: 1782
Re: Bring TImage to front of TEdit
« Reply #1 on: February 13, 2020, 10:05:34 pm »
Hi!

I am not a visionary!

Image1 is maginifier??

What is the other component?

Are you in a loop while you do: Image1.BringToFront - then you should insert
Application.ProcessMessages to let the Image some time to breath - or let's say: to handle all events in the queu.

Winni
Need some more info or source.

Winni

SaraT

  • Jr. Member
  • **
  • Posts: 86
  • A little student
Re: Bring TImage to front of TEdit
« Reply #2 on: February 13, 2020, 10:09:08 pm »
Hi!

I am not a visionary!

Image1 is maginifier??

What is the other component?

Are you in a loop while you do: Image1.BringToFront - then you should insert
Application.ProcessMessages to let the Image some time to breath - or let's say: to handle all events in the queu.

Winni
Need some more info or source.

Winni

The components are: TEdit and TImage
I have tried with Z-order and Image.BringToFront but don't work :/

I need another idea. Thanks

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: Bring TImage to front of TEdit
« Reply #3 on: February 13, 2020, 10:24:38 pm »
Is not possible. TImage is TGraphicControl descendant and TEdit is TWinControl desdendant and doesn't accept to put controls (any) in top of it, at least is what I know.

TGraphicControl are drawn in top of a Canvas, like a Panel or a Form.

winni

  • Hero Member
  • *****
  • Posts: 1782
Re: Bring TImage to front of TEdit
« Reply #4 on: February 13, 2020, 10:36:02 pm »
So put you magnifyer in a second mini form and show it.

Winni

lucamar

  • Hero Member
  • *****
  • Posts: 3019
Re: Bring TImage to front of TEdit
« Reply #5 on: February 13, 2020, 10:45:00 pm »
Maybe too obvious but, have you tried sending the TEdit to the back instead? I mean, using: MyEdit.SendToBack

I'm not sure at all  whether that will work but it's worth a try ...
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

korba812

  • Full Member
  • ***
  • Posts: 134
Re: Bring TImage to front of TEdit
« Reply #6 on: February 13, 2020, 10:48:33 pm »
You can try to compose such component using standard controls. See the attached example.

SaraT

  • Jr. Member
  • **
  • Posts: 86
  • A little student
Re: Bring TImage to front of TEdit
« Reply #7 on: February 14, 2020, 01:22:29 am »
You can try to compose such component using standard controls. See the attached example.
Thanks, but unable to open the project. It is blank I dont know why.

winni

  • Hero Member
  • *****
  • Posts: 1782
Re: Bring TImage to front of TEdit
« Reply #8 on: February 14, 2020, 01:46:50 am »
@SaraT

Yes, you are right:

"The project has no main source file" - after opening the unit manual.

What is your goal with the Edit component and the magnifier?

Winni

SaraT

  • Jr. Member
  • **
  • Posts: 86
  • A little student
Re: Bring TImage to front of TEdit
« Reply #9 on: February 14, 2020, 02:07:26 am »
You can try to compose such component using standard controls. See the attached example.

Thanks guys :)
I was able to do it with this sample. The project is blank but you can open the .pas file ans see how it works.

Many thanks again  8)
You can see it in action in the gif below.


skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2514
    • havefunsoft.com
Re: SOLVED: Bring TImage to front of TEdit
« Reply #10 on: February 14, 2020, 05:10:46 am »
oddly enough "embedding buttons into controls" is following me lately.

anyways, Lazarus provides a default solution for such task: TEditButton
(can be found at TEditButton) (see "Misc" tab)

doesn't look as fancy, but it does the job. (and is used throughout IDE itself)
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

El Salvador

  • New Member
  • *
  • Posts: 13
Re: SOLVED: Bring TImage to front of TEdit
« Reply #11 on: July 18, 2020, 11:59:46 am »
So, you have only this possibility to make a TEdit component with left/right buttons embedding in it? I'm trying make a TCustomEdit based with buttons in it, following this tip https://wiki.lazarus.freepascal.org/TEdit#Embedding_Button.2FOther_Controls_in_TEdit, but I have repainting issues (especially when I select text).

PascalDragon

  • Hero Member
  • *****
  • Posts: 2107
  • Compiler Developer
Re: Bring TImage to front of TEdit
« Reply #12 on: July 18, 2020, 01:51:45 pm »
You can try to compose such component using standard controls. See the attached example.
Thanks, but unable to open the project. It is blank I dont know why.

It is blank because the author used Lazarus 2.1 and forgot to enable "Increase compatibility of project" so that it is stored in a format that is useable by Lazarus 2.0 as well.

furious programming

  • Sr. Member
  • ****
  • Posts: 467
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
Re: SOLVED: Bring TImage to front of TEdit
« Reply #13 on: July 18, 2020, 06:48:32 pm »
If you can't get Edit to embed an image/button component, there's always another trick.

Take a Panel, turn off its border and in the OnPaint event paint it like Edit — just use ThemeServices. Then take Edit, turn off its border and embed it in the panel. Next to Edit, place the component with the image (button or whatever you like) and also embed it in the panel.

And that's it — everything looks like it should and has appropriate margins, thanks to which the image will not cover the text. In this way you can embed what you need and where you need.
« Last Edit: July 18, 2020, 06:50:38 pm by furious programming »
Lazarus 2.0.10 with FPC 3.2.0 (SVN Revision 63526), Windows XP (all 32-bit)

dtamadeEx

  • New Member
  • *
  • Posts: 10
Re: SOLVED: Bring TImage to front of TEdit
« Reply #14 on: July 23, 2020, 07:58:27 pm »
Rewriting a text box might be a better solution


 

TinyPortal © 2005-2018