Recent

Author Topic: Handling of all events of Form and children  (Read 2136 times)

yurkad

  • Full Member
  • ***
  • Posts: 173
  • development
Handling of all events of Form and children
« on: January 21, 2019, 04:50:31 pm »
Please, I need documentation about handling of all events of Form and children.

Especially about capture event "OnChangeBounds" of Form and children.
Perhaps somebody can provide a sample of this.

If is possible not "only for Windows".

Many thanks.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Handling of all events of Form and children
« Reply #1 on: January 21, 2019, 06:47:57 pm »
What do you mean?

OnChangeBounds is a published event so you can set a handler in the normal way: in code or through the object inspector.

If what you want is to execute some code before the event handler is called then see this (similar) thread: Intercept DBGrid OnColumnMove
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

yurkad

  • Full Member
  • ***
  • Posts: 173
  • development
Re: Handling of all events of Form and children
« Reply #2 on: January 21, 2019, 08:36:26 pm »
Thank you, lucamar.

OnChangeBounds is a published event so you can set a handler in the normal way: in code or through the object inspector.

It is thus. Is necessary make much place for capture events. Around 10 procedurs for each control.
In my case is not possible choose this way.

I need capture all events from only one place of app.
 
« Last Edit: January 21, 2019, 08:41:01 pm by yurkad »

yurkad

  • Full Member
  • ***
  • Posts: 173
  • development
Re: Handling of all events of Form and children
« Reply #3 on: January 21, 2019, 09:19:58 pm »
That I need is code of procedure:

TSomeForm.CaptureEventsOfForm(obj:TObject);

This procedure will last in form event OnShow:
 
Code: Pascal  [Select][+][-]
  1. procedure TSomeForm.FormShow(Sender: TObject);
  2. begin
  3. ...
  4. CaptureEventsOfForm(self);
  5. end;

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Handling of all events of Form and children
« Reply #4 on: January 21, 2019, 11:17:24 pm »
Let me test my understanding: what you want is an event dispatcher, i.e. a function/procedure which responds to *all* the form events, does whatever it needs and then calls the proper event handler, if any. Is that it?

I don't think that will be easy. Your best bet may be setting a kind of message-loop like that in TAplication but AFAIK TCustomForm hasn't any facilities to do it easily.

Let me sleep on it and maybe I can think of something.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: Handling of all events of Form and children
« Reply #5 on: January 21, 2019, 11:46:17 pm »
Thank you, lucamar.

OnChangeBounds is a published event so you can set a handler in the normal way: in code or through the object inspector.

It is thus. Is necessary make much place for capture events. Around 10 procedurs for each control.
In my case is not possible choose this way.

I need capture all events from only one place of app.
there is no way to do something like this. On windows non active controls do not receive messages that include the containers of the active controls too. Your only solution would be to write a loop that finds all the controls in a forms (use the form.controls property for that) and attach the same event handle to each one by code.

yurkad

  • Full Member
  • ***
  • Posts: 173
  • development
Re: Handling of all events of Form and children
« Reply #6 on: January 22, 2019, 12:48:16 am »
lucamar, thank you by attention.
Please, sleep calm. I already have a plan.


HeavyUser, thank you by good advice.
I do not think that your plan is the only plan.
But nevertheless by now I will make according of  this plan.
This only temporary. After solve I will find unother solution.

In one - two days I will publish first solution.

Thanks.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Handling of all events of Form and children
« Reply #7 on: January 22, 2019, 12:52:49 am »
it seems you maybe making a Drag and drop or some sort of building block application where the
controls are not actually doing anything except modeling the form in the same way Laz does now.

 I like the idea of enumerating through all of the controls and assigning their events to a single handler of
each type. This way you can test the Sender parameter to know who it is.

 Actually, I do such thing now with a small program I have  :D
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018