Recent

Author Topic: BringToFront  (Read 946 times)

pascal111

  • Sr. Member
  • ****
  • Posts: 420
  • Un trabajo en equipo para programas serias.
BringToFront
« on: June 30, 2022, 06:09:25 pm »
How "BringToFront" can affect on forms although forms are derived from "TForm" calls and "BringToFront" isn't a member of the same class but rather it's a member of "TApplication"?

BringToFront is in:
https://lazarus-ccr.sourceforge.io/docs/lcl/forms/tapplication.html

TForm:
https://lazarus-ccr.sourceforge.io/docs/lcl/forms/tform.html

A code from https://wiki.freepascal.org/Form_Tutorial

Code: Pascal  [Select][+][-]
  1. procedure TCustomForm.Show;
  2. begin
  3.   Visible := True;
  4.   BringToFront;
  5. end;
  6.  
La chose par la chose est rappelé.

PascalDragon

  • Hero Member
  • *****
  • Posts: 4325
  • Compiler Developer
Re: BringToFront
« Reply #1 on: July 01, 2022, 01:40:02 pm »
How "BringToFront" can affect on forms although forms are derived from "TForm" calls and "BringToFront" isn't a member of the same class but rather it's a member of "TApplication"?

If you do a Ctrl+Click on BringToFront you'll see that it's in fact provided by TControl (which is one of the ancestors of TForm). If you want to access the BringToFront of the Application you need to use Application.BringToFront.

pascal111

  • Sr. Member
  • ****
  • Posts: 420
  • Un trabajo en equipo para programas serias.
Re: BringToFront
« Reply #2 on: July 01, 2022, 04:19:26 pm »
Quote
If you do a Ctrl+Click on BringToFront you'll see that it's in fact provided by TControl (which is one of the ancestors of TForm). If you want to access the BringToFront of the Application you need to use Application.BringToFront.

Your words reveal that there are two "BringToFront"'s. Is this true?
La chose par la chose est rappelé.

winni

  • Hero Member
  • *****
  • Posts: 3126
Re: BringToFront
« Reply #3 on: July 01, 2022, 04:28:20 pm »

Your words reveal that there are two "BringToFront"'s. Is this true?

If you don't believe it:

Look into the sources.

Winni

pascal111

  • Sr. Member
  • ****
  • Posts: 420
  • Un trabajo en equipo para programas serias.
Re: BringToFront
« Reply #4 on: July 01, 2022, 04:59:50 pm »
Quote
If you don't believe it:

Look into the sources.

Forgive me! I don't understand your English. This isn't what my reply was about.
La chose par la chose est rappelé.

speter

  • Sr. Member
  • ****
  • Posts: 278
Re: BringToFront
« Reply #5 on: July 02, 2022, 07:53:18 am »
pascal111, there is a saying "don't give a person a fish; teach them how to fish".
If you give someone a fish, they have a single meal; if they learn to fish they can get many meals...

Winni, may not have been answering your question; but they (instead) were telling you how to work out the answer yourself - which may be useful "learning" for many future "problems".

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.2.0 / FPC 3.2.2 / Windows 11 (64bit)

pascal111

  • Sr. Member
  • ****
  • Posts: 420
  • Un trabajo en equipo para programas serias.
Re: BringToFront
« Reply #6 on: July 02, 2022, 10:14:38 am »
Quote
pascal111, there is a saying "don't give a person a fish; teach them how to fish".
If you give someone a fish, they have a single meal; if they learn to fish they can get many meals...

This is not an appropriate situation of the fish proverb, and the same proverb if it used in inappropriate way, it will be an insult instead of a wise beautiful words like when you say it to a lazy person who doesn't want to make any effort because with that way you are blaming him. I have some experience with proverbs in both Arabic and English  :)

Quote
Winni, may not have been answering your question; but they (instead) were telling you how to work out the answer yourself - which may be useful "learning" for many future "problems".

I'm not blaming @winni at all, I tried to say that he is away of my point, he misunderstands my replay to @dargon. My reply meant what is the difference between the function of each one of "BringToFront"?
« Last Edit: July 02, 2022, 10:17:11 am by pascal111 »
La chose par la chose est rappelé.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4782
Re: BringToFront
« Reply #7 on: July 02, 2022, 10:48:44 am »
Quote
pascal111, there is a saying "don't give a person a fish; teach them how to fish".
If you give someone a fish, they have a single meal; if they learn to fish they can get many meals...

This is not an appropriate situation of the fish proverb, and the same proverb if it used in inappropriate way, it will be an insult instead of a wise beautiful words like when you say it to a lazy person who doesn't want to make any effort because with that way you are blaming him. I have some experience with proverbs in both Arabic and English  :)

Well, you've just added to your experience of English proverbs by improving your understanding of the "fish" one.

More relevant is the experience you have of searching for identifiers in the LCL sources, or using the documentation. A good place to start in this case is https://lazarus-ccr.sourceforge.io/docs/lcl/ , but you are going to have to do some of your own legwork since indexing is incomplete.

With the usual caveat that detail might depend on the Window Manager or desktop environment being used, I think the point being made is that there might be a distinction between bringing an entire app to the front and bringing a specific form to the front.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

pascal111

  • Sr. Member
  • ****
  • Posts: 420
  • Un trabajo en equipo para programas serias.
Re: BringToFront
« Reply #8 on: July 02, 2022, 11:27:39 am »
Quote
Well, you've just added to your experience of English proverbs by improving your understanding of the "fish" one.

I didn't add anything to my experience of English proverbs, because of two things my dear @MarkMLl:

1) It will be wrong English if I accepted the meaning @speter meant, and this meaning supports the misunderstanding of @winni, and I explained that in the ignored part when I said "This is not an appropriate situation of the fish proverb, and the same proverb if it used in inappropriate way, it will be an insult instead of a wise beautiful words like when you say it to a lazy person who doesn't want to make any effort because with that way you are blaming him. I have some experience with proverbs in both Arabic and English  :)", so adding this meaning is insisting on accepting wrong English.

2) The correct proverb isn't "don't give a person a fish; teach them how to fish", but rather in translated version I read meant "don't give me a fish; but teach me how to fish", and there are a so big difference between the two proverbs.

Quote
More relevant is the experience you have of searching for identifiers in the LCL sources, or using the documentation. A good place to start in this case is https://lazarus-ccr.sourceforge.io/docs/lcl/ , but you are going to have to do some of your own legwork since indexing is incomplete.

This won't answer the difference between the two "BringToFront" except maybe if I'm so expert in the language, but I think you need to notice that this section is for beginners, so for a beginner it'll be not sensible in many cases to make an "own legwork" to search for the differences between similar instructions or understanding some accurate details, I think forum is for that.

Quote
With the usual caveat that detail might depend on the Window Manager or desktop environment being used, I think the point being made is that there might be a distinction between bringing an entire app to the front and bringing a specific form to the front.

I think this can help to answer my inquiry.
La chose par la chose est rappelé.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4782
Re: BringToFront
« Reply #9 on: July 02, 2022, 12:22:20 pm »
1) It will be wrong English if I accepted the meaning ... 2) The correct proverb isn't "don't give a person a fish; teach them how to fish", but rather in translated version I read meant "don't give me a fish; but teach me how to fish", ...

With respect, you say that your experience is limited so I suggest that it is inappropriate to pontificate. See e.g. https://quoteinvestigator.com/2015/08/28/fish/ for a discussion, and note that none of it is intended to be derogatory towards the recipient of the assistance.

It's not often that I stand up for Winni, since he is accustomed to writing in haste and sometimes his comments are... less than helpful. However in this case I think he is making a reasonable point.

I suggest that further discussion here is off-topic.

Quote
This won't answer the difference between the two "BringToFront" except maybe if I'm so expert in the language, but I think you need to notice that this section is for beginners, so for a beginner it'll be not sensible in many cases to make an "own legwork" to search for the differences between similar instructions or understanding some accurate details, I think forum is for that.

I've given you a documentation link. Like a beginner in any subject, you are expected to learn to use that sort of thing.

Quote
Quote
With the usual caveat that detail might depend on the Window Manager or desktop environment being used, I think the point being made is that there might be a distinction between bringing an entire app to the front and bringing a specific form to the front.

I think this can help to answer my inquiry.

I would emphasise that you (and anybody else who gets here via Google etc.) do have to be very careful there. In particular, if using Linux the behaviour is likely to vary depending on the Window Manager the particular distro is using, and depending on the widgetset (i.e. gtk vs Qt and so on).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

pascal111

  • Sr. Member
  • ****
  • Posts: 420
  • Un trabajo en equipo para programas serias.
Re: BringToFront
« Reply #10 on: July 02, 2022, 12:50:31 pm »
Quote
With respect, you say that your experience is limited so I suggest that it is inappropriate to pontificate. See e.g. https://quoteinvestigator.com/2015/08/28/fish/ for a discussion, and note that none of it is intended to be derogatory towards the recipient of the assistance.

"your experience is limited", where I said my experience is limited?!!!, and limited in what, lazarus, English, life ...etc, I think this is an obscure phrase, and suppose that I said that, it meant that as a beginner I have the right in direct clear explaining for what I'm asking for, not to make it more complicated.

"I suggest that it is inappropriate to pontificate", any native English person in England and native Arabic person in Arabia will understand this phrase as an insult, but I know this is not your intention. It's not meaning that if someone is limited in his knowledge that others have the right to redirect him according to their interests, not his own interest.

Quote
It's not often that I stand up for Winni, since he is accustomed to writing in haste and sometimes his comments are... less than helpful. However in this case I think he is making a reasonable point.

I never blamed him, I said he misunderstood me, that is  :)

Quote
I suggest that further discussion here is off-topic.

I'm with you that we don't need to talk in these points again.

Quote
I've given you a documentation link. Like a beginner in any subject, you are expected to learn to use that sort of thing.

Documentations have many sorts, and some of 'em are for further reading for intermediate and expert learners.

Quote
I would emphasise that you (and anybody else who gets here via Google etc.) do have to be very careful there. In particular, if using Linux the behaviour is likely to vary depending on the Window Manager the particular distro is using, and depending on the widgetset (i.e. gtk vs Qt and so on).

For that we are asking our questions in the forum to get the help from advanced users who have knowledge better than us.
La chose par la chose est rappelé.

PascalDragon

  • Hero Member
  • *****
  • Posts: 4325
  • Compiler Developer
Re: BringToFront
« Reply #11 on: July 02, 2022, 04:36:09 pm »
Quote
If you do a Ctrl+Click on BringToFront you'll see that it's in fact provided by TControl (which is one of the ancestors of TForm). If you want to access the BringToFront of the Application you need to use Application.BringToFront.

Your words reveal that there are two "BringToFront"'s. Is this true?

There is TApplication.BringToFront and TControl.BringToFront. The former can be used to make sure (or at least to try to) that the main form or current modal form of the application is at the front of all applications that are running. The later is to bring the specific control to front (which can either be some small widget like two TButton that overlap each other or a form that you want to bring in front of the other form's of the application).

pascal111

  • Sr. Member
  • ****
  • Posts: 420
  • Un trabajo en equipo para programas serias.
Re: BringToFront
« Reply #12 on: July 02, 2022, 04:55:47 pm »
Quote
There is TApplication.BringToFront and TControl.BringToFront. The former can be used to make sure (or at least to try to) that the main form or current modal form of the application is at the front of all applications that are running. The later is to bring the specific control to front (which can either be some small widget like two TButton that overlap each other or a form that you want to bring in front of the other form's of the application).

Thank you for this straightforward explaining without confusion. Can I ask more question? I understood that "TApplication.BringToFront" is the one brings specific control to front, but this make us think that components are a part of TApplication class rather than TControl class. Did I miss something here or am I right?
La chose par la chose est rappelé.

Handoko

  • Hero Member
  • *****
  • Posts: 4696
  • My goal: build my own game engine using Lazarus
Re: BringToFront
« Reply #13 on: July 03, 2022, 04:06:35 am »
https://lazarus-ccr.sourceforge.io/docs/lcl/forms/tapplication.html
https://lazarus-ccr.sourceforge.io/docs/lcl/controls/tcontrol.html

Those above say:
TApplication.BringToFront -> asks the widgetset to bring the application's form(s) to the front
TControl.BrintToFront -> bring the control in front of all sibling controls

TApplication can bring the application's from(s) to the front because the widgetset internally has a list of information of all forms so it knows how to find the form(s) and bring them to front.

If you inspect into the source code of TControl, you will know:
TControl.BringToFront basically just ask its parent to reorder the forms' orders. The parent can do so because it maintains a list of all forms belong to it.

TForm is a descendant of TControl, indirectly. TApplication is not a descendant of TControl. But both TApplication and TControl are indirectly inherited from TCompoment.
         
« Last Edit: July 03, 2022, 07:46:56 am by Handoko »

PascalDragon

  • Hero Member
  • *****
  • Posts: 4325
  • Compiler Developer
Re: BringToFront
« Reply #14 on: July 03, 2022, 02:35:27 pm »
Quote
There is TApplication.BringToFront and TControl.BringToFront. The former can be used to make sure (or at least to try to) that the main form or current modal form of the application is at the front of all applications that are running. The later is to bring the specific control to front (which can either be some small widget like two TButton that overlap each other or a form that you want to bring in front of the other form's of the application).

Thank you for this straightforward explaining without confusion. Can I ask more question? I understood that "TApplication.BringToFront" is the one brings specific control to front, but this make us think that components are a part of TApplication class rather than TControl class. Did I miss something here or am I right?

You confused the two:
  • TApplication.BringToFront: bring the active form(s) of the application to the front of all applications in the system (or at least tries to do so; this behavior depends on (especially on Linux) whether the window manager of the system handles this correctly)
  • TControl.BringToFront: bring the control to the front in relation to all direct siblings (not involing parents or children); if used on a form, bring the form in the foreground of all forms of the current application (as they're all sibling “controls”)

 

TinyPortal © 2005-2018