Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread User Defined Notifications
Thu, Jun 28 2018 2:58 PMPermanent Link

Mark Brooks

Slikware

Avatar

Question for Tim or anybody else who's already done this.

I "think" that the EWB framework provides a mechanism to send a user-defined notification to all instances of a specific TControl descendant? I want to let all TBasicPanel descendants in my app know about something. Does anybody have sample code to achieve this? Also, can any form of scope be applied?

Thanks in advance
Mark
Fri, Jun 29 2018 4:03 AMPermanent Link

Matthew Jones

Mark Brooks wrote:

> mechanism to send a user-defined notification to all instances of a specific TControl descendant?

Not that I'm aware of. There is a way to use any single instance as a transmission post for a message. That will work well for some people, but when I did this I used a more generic message system that anything can register with and receive notifications by an ID. Search the newsgroup for TNotificationEvent for the source. Not sure it will do what you are wanting, unless you have your components all register automatically.

--

Matthew Jones
Fri, Jun 29 2018 7:43 AMPermanent Link

Mark Brooks

Slikware

Avatar

Ah yes ....... now I remember (age is a terrible thing)
Fri, Jun 29 2018 1:28 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< I "think" that the EWB framework provides a mechanism to send a user-defined notification to all instances of a specific TControl descendant? I want to let all TBasicPanel descendants in my app know about something. Does any body have sample code to achieve this? Also, can any form of scope be applied? >>

It's functionality that is in the TComponent class, and yes, it will allow for this:

Register with a component for notifications:

https://www.elevatesoft.com/manual?action=viewmethod&id=ewb2&comp=TComponent&method=Register

Un-register:

https://www.elevatesoft.com/manual?action=viewmethod&id=ewb2&comp=TComponent&method=UnRegister

The other important methods are protected and one needs to be overridden in order to implement your functionality:

Sending notification:

procedure TComponent.Notify(ID: Integer; Data: TObject=nil);

Receiving notification (need to override):

function TComponent.Notification(Sender: TComponent; ID: Integer; Data: TObject): Boolean;

Both are in the WebCore unit.

You'll also notice that the Notification method returns a result.  When true, the result serves to tell the notification broadcasting (Notify) to stop notifying other components after this point, which is useful when you have a multiple notification types, but one or more of the notification types are only actually targeted at one particular listener and you want to stop notifying once that listener receives the notification.

When defining notifications, make sure that you use cmUser constant (defined in the WebCore unit) as the base value, and you'll be all set and won't interfere with any internal EWB notifications.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jul 2 2018 3:18 AMPermanent Link

Mark Brooks

Slikware

Avatar

All good thanks - appreciate the recap
Image