Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Generic message handling?
Fri, Apr 29 2016 4:59 AMPermanent Link

Matthew Jones

Is there a way to send a generic message to a component or similar? In
particular I'm talking about a TForm, but my virtual list would be
better if I could send an arbitrary message without knowing the type of
the form. In WIndows, this could be some sort of registered message, or
WM_USER etc, which would be ignored by a form that didn't know about
it. Now, obviously the browser doesn't have a message queue for windows
because they aren't windows, but is there any other sort of thing that
would have the same capability? I guess the ideal would be a virtual
that accepts an object as parameter. The component can then say "if
Parameter is TMySpecialObject" and if not, pass it on, otherwise
process it.

Anyone got ideas on this?

And indeed, if I have a TForm derived form, can I "inject" my own form
type into the middle by altering the source to make my own message
handler like this? So I'd have TMyDetailForm derived from TMessageForm
derived from TForm. But the IDE would allow TMyDetailForm to work as
usual.

--

Matthew Jones
Fri, Apr 29 2016 5:54 AMPermanent Link

Matthew Jones

Matthew Jones wrote:

> And indeed, if I have a TForm derived form, can I "inject" my own form
> type into the middle by altering the source to make my own message
> handler like this? So I'd have TMyDetailForm derived from TMessageForm
> derived from TForm. But the IDE would allow TMyDetailForm to work as
> usual.

FWIW, yes, it will. I can pass a message via object to an intermediate
form type. Would be nice to have in the base class somehow, as a
general advanced messaging mechanism, but it can be done oneself.

--

Matthew Jones
Fri, Apr 29 2016 12:52 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Is there a way to send a generic message to a component or similar? >>

Check out the notification support in the TComponent class (WebCore).  As long as a component registers itself for notification, then you can notify all registered components.  You can also call a TComponent instance's Notification method directly with an ID and an object reference.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Apr 29 2016 2:14 PMPermanent Link

Matthew Jones

Tim Young [Elevate Software] <timyoung@elevatesoft.com> wrote:
> Matthew,
>
> << Is there a way to send a generic message to a component or similar? >>
>
> Check out the notification support in the TComponent class (WebCore).  As
> long as a component registers itself for notification, then you can
> notify all registered components.  You can also call a TComponent
> instance's Notification method directly with an ID and an object reference.
>

Sounds like you have this one covered too. Thank you.

--
Matthew Jones
Sun, May 1 2016 5:33 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> << Is there a way to send a generic message to a component or
> similar? >>
>
> Check out the notification support in the TComponent class (WebCore).
> As long as a component registers itself for notification, then you
> can notify all registered components.  You can also call a TComponent
> instance's Notification method directly with an ID and an object
> reference.

Looks perfect. Can I suggest you add another constant to your list of
notifications, which is the start of application defined ones? Like
WM_USER or WM_APPLICATION.

cmRemoveComp = 3;
cmApplication = 500;

Then we can define ours as offset of that.

cmMyNotify = cmApplication + 1;

Then we can be guaranteed that there won't be a clash in future.
(Obviously this is easy to do ourselves, but if in the library, it
becomes sanctioned.)

--

Matthew Jones
Mon, May 2 2016 2:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Looks perfect. Can I suggest you add another constant to your list of notifications, which is the start of application defined ones? Like WM_USER or WM_APPLICATION. >>

I added this to the WebCore unit's interface:

  cmUser = 1000;

Tim Young
Elevate Software
www.elevatesoft.com
Image